Skip to content

Commit

Permalink
remove the timeout on browsers connecting then sending request since …
Browse files Browse the repository at this point in the history
…firefox just connects and then leaves it open ready to use :(
  • Loading branch information
deanhiller committed Aug 27, 2016
1 parent bbae7ba commit 79614c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ public class FrontendConfig {

/**
* When a client connects, they must send a request in this amount of timer. null means disabled.
* Firefox connects pre-emptively ALL the time without making requests which is annoying so we default
* this to null
*/
public Integer maxConnectToRequestTimeoutMs = 4000;

/**
* null means keep alive will be disabled
*/
public Integer keepAliveTimeoutMs = 15000;
public Integer maxConnectToRequestTimeoutMs = null;

/**
* The max size a client may send. I advise not too large a limit here or DOS attacks become easier in that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public HttpFrontend createHttpServer(FrontendConfig config, HttpRequestListener
}

private void preconditionCheck(FrontendConfig config) {
if(config.keepAliveTimeoutMs != null && timer == null)
throw new IllegalArgumentException("keepAliveTimeoutMs must be null since no timer was given when HttpFrontendFactory.createFrontEnd was called");
else if(config.maxConnectToRequestTimeoutMs != null && timer == null)
if(config.maxConnectToRequestTimeoutMs != null && timer == null)
throw new IllegalArgumentException("keepAliveTimeoutMs must be null since no timer was given when HttpFrontendFactory.createFrontEnd was called");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ public void configure(Binder binder) {
binder.bind(WebServerConfig.class).toInstance(config);
}

@Provides
@Singleton
public ScheduledExecutorService provideTimer() {
return new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
}
// Firefox keeps connecting pre-emptively with no requests for seconds (maybe so it is ready to just send one when needed)
// @Provides
// @Singleton
// public ScheduledExecutorService provideTimer() {
// return new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
// }

@Provides
@Singleton
public HttpFrontendManager providesAsyncServerMgr(WebServerConfig config, ScheduledExecutorService timer) {
return HttpFrontendFactory.createFrontEnd("httpFrontEnd", config.getNumFrontendServerThreads(), timer);
public HttpFrontendManager providesAsyncServerMgr(WebServerConfig config) {
return HttpFrontendFactory.createFrontEnd("httpFrontEnd", config.getNumFrontendServerThreads(), null);
}

}

0 comments on commit 79614c6

Please sign in to comment.