Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

SocketTimeoutException #621

Open
vaditya04 opened this issue Oct 12, 2018 · 1 comment
Open

SocketTimeoutException #621

vaditya04 opened this issue Oct 12, 2018 · 1 comment

Comments

@vaditya04
Copy link

Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at io.searchbox.client.http.JestHttpClient.executeRequest(JestHttpClient.java:132)
at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:67)
at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:60)

We're facing recurring errors in production of this kind. My working theory is based on this SO post https://stackoverflow.com/questions/48236832/jestclient-is-throwing-sockettimeoutexception-after-being-idle-for-sometime?rq=1

In other words I think we need to configure maxConnectionIdleTime, and other related values correctly.

My questions:

  1. What is the default value of maxConnectionIdleTime?

  2. Should connTimeout necessarily be greater than maxConnectionIdleTime (the SO post suggests it)? Our application has connTimeout set to 5 ms (Is this too small?), and no value at all for maxConnectionIdleTime. Also readTimeout is 1000 ms.

  3. Is there any guidance on how to go about setting these values, and the significance of each?

Feel free to resolve this if there isn't enough information provided, I'm in the starting stage of debugging this so not sure what I should be looking at.

@chengaofeng
Copy link

hi @vaditya04 ,I have the same problem with you ,When my application is idle for some time, the JestClient is throwing SocketTImeoutException.After adding the maxConnectionIdleTime configuraition, "llegalStateException: Expected the service to be RUNNING, but the service has FAILED" comes up.

I debugged my app, foud the Exception is from com.google.common.util.concurrent.AbstractService(checkCurrentState method).

Through further debugging,I foud the real reason is from com.google.common.util.concurrent.AbstractService.startAsync method,in this method ,it calls doStart, which cause a "java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;"

At last, I found the result is due to jar package conflicts. With jest:5.3.3,we need guava:21.0, while in my maven project, what we truly used is guava:15.0. When I fixed this problem, my app is running successfully, and the SocketTImeoutException hasn't appeared for some time .

I hope this will help you.

the configuration for jest in my app:

HttpClientConfig.Builder builder = new HttpClientConfig.Builder(Arrays.asList(uris)) .multiThreaded(true) .maxConnectionIdleTime(10000, TimeUnit.MILLISECONDS) .maxTotalConnection(20) .defaultMaxTotalConnectionPerRoute(2) .readTimeout(15000).connTimeout(15000);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants