We have an application lets say A (written in Java + GWT) deployed on server box "X" From application A lets say we load some reports located on server box "Y"
The flow of the every incoming request is something like below
web user(client) -> apache -> jboss(application A is deployed here on server X) -> server box Y from where reports are being pulled.
Once the request comes to apache then session inactivity timeout is set to 30 minutes.
When a request is being made from jboss(server X) -> server Y to pull reports, we have made sure to timeout that request after 25 minutes, so that this will prevent the apache from showing a 503 when the server Y takes too long to respond.
Even after that its getting timed out after 20 minutes. Probable reason could be firefox browser may have its own timeout of 20 minutes for any request to handle.
Some of the code snippet for reference
HttpClient httpclient = HttpClientBuilder.create().setDefaultRequestConfig(getRequestConfig()).setRedirectStrategy(new LaxRedirectStrategy()).setSSLSocketFactory(getSSLContext()).build();
HttpClientContext context = HttpClientContext.create();
HttpPost httppost = new HttpPost(urlString); // urlString is reports server url
HttpResponse httpResponse = httpclient.execute(httppost, context);
Now to fix firefox browser issue, we thought of changing existing RequestConfig from
private RequestConfig getRequestConfig() {
return RequestConfig.custom().setSocketTimeout(REPORT_SERVER_READ_TIMEOUT_IN_SECONDS * 1000).build();
}
to
private RequestConfig getRequestConfig() {
return RequestConfig.custom().setConnectTimeout(REPORT_SERVER_READ_TIMEOUT_IN_SECONDS * 1000).setSocketTimeout(REPORT_SERVER_READ_TIMEOUT_IN_SECONDS * 1000).build();
}
REPORT_SERVER_READ_TIMEOUT_IN_SECONDS is set to 1100 seconds.
With this change it times out after 1100 seconds, but we see an error message on browser as
"The connection to the server was reset while the page was loading"
On server log we see error-log as
Exception: : java.io.IOException: Internal TLS error, this could be an attack
at org.bouncycastle.crypto.tls.TlsProtocol.failWithError(Unknown Source) [:1.57.0]
at org.bouncycastle.crypto.tls.TlsProtocol.safeReadRecord(Unknown Source) [:1.57.0]
at org.bouncycastle.crypto.tls.TlsProtocol.readApplicationData(Unknown Source) [:1.57.0]
at org.bouncycastle.crypto.tls.TlsInputStream.read(Unknown Source) [:1.57.0]
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136) [:4.0.1]
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152) [:4.0.1]
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270) [:4.0.1]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140) [:4.3.6]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) [:4.3.6]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260) [:4.0.1]
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:161) [:4.3.3]
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153) [:4.3.6]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271) [:4.0.1]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123) [:4.0.1]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254) [:4.3.6]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195) [:4.3.6]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86) [:4.3.6]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108) [:4.3.6]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) [:4.3.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) [:4.3.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) [:4.3.6]
Anyone has any idea about fixing browser specific timeout?
while creating HttpClient I set setSSLSocketFactory. The way I set it like below:
private SSLConnectionSocketFactory getSSLContext() throws Exception {
return new SSLConnectionSocketFactory(new TLSSocketConnectionFactory(), new String[] { "TLSv1.2" }, null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}
When I looked at SSLConnectionSocketFactory
public SSLConnectionSocketFactory(SSLSocketFactory socketfactory, String supportedProtocols[], String supportedCipherSuites[], X509HostnameVerifier hostnameVerifier)
{
this.socketfactory = (SSLSocketFactory)Args.notNull(socketfactory, "SSL socket factory");
this.supportedProtocols = supportedProtocols;
this.supportedCipherSuites = supportedCipherSuites;
this.hostnameVerifier = hostnameVerifier == null ? BROWSER_COMPATIBLE_HOSTNAME_VERIFIER : hostnameVerifier;
}
SSLSocketFactory is deprecated. Can that cause an issue?