-
Notifications
You must be signed in to change notification settings - Fork 241
ConsulCache throws java.net.SocketTimeoutException: timeout #135
Comments
You are using "default" newCache method that with You can use 'org.glassfish.jersey.core:jersey-client:2.22.1' Or Build consul instance with custom connection. Hope I'm right. and it helped you |
Thanks, use withReadTimeoutMillis(20000) to build consul client can fix the problem. |
Also stepped on this one. |
By default Consul has a watch/read timeout greater than the http library that it uses which causes the client to enter a timeout exception loop. Setting a default read timeout of 20 seconds mitigates this problems rickfast/consul-client#135 Signed-off-by: Tommy Shiou <[email protected]>
Me to, what the status of this? I think default values should be fixed to avoid such error... |
Yup, stepped on this one as well. Thanks for helping out! |
Here's why increasing the OkHttp read timeout helps. There are two timers in a cache. One is the read timeout, which is how long OkHttp will wait for a response (OkHttp default is 10s). The second is the blocking request wait time. The client makes a call, and if there is no change then Consul waits at most this amount of time to reply "no change". But see this in their docs (https://www.consul.io/api/index.html#blocking-queries):
What's happening is that that jitter makes Consul reply in slightly longer than 10s, which makes OkHttp time out. I think the client should use maybe 9s wait time by default to avoid this. Note that the |
Hi,
When I use ServiceHealthCache to register a watch service changes, once I start the service heath cache, I got the timeout error every 10s.
[OkHttp http://localhost:8500/v1/health/service/TEST001?index=793&wait=10s&passing=true] ERROR [com.orbitz.consul.cache.ConsulCache] - Error getting response from consul. will retry in 10 SECONDS
java.net.SocketTimeoutException: timeout
at com.orbitz.okio.Okio$3.newTimeoutException(Okio.java:207)
at com.orbitz.okio.AsyncTimeout.exit(AsyncTimeout.java:261)
at com.orbitz.okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
at com.orbitz.okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at com.orbitz.okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at com.orbitz.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.orbitz.okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:184)
at com.orbitz.okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:125)
at com.orbitz.okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:723)
at com.orbitz.okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:81)
at com.orbitz.okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:708)
at com.orbitz.okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
at com.orbitz.okhttp3.RealCall.getResponse(RealCall.java:241)
at com.orbitz.okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
at com.orbitz.okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
at com.orbitz.okhttp3.RealCall.access$100(RealCall.java:30)
at com.orbitz.okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at com.orbitz.okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at com.orbitz.okio.Okio$2.read(Okio.java:139)
at com.orbitz.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
... 18 more
The text was updated successfully, but these errors were encountered: