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

consul health client timeout #180

Open
EvertMDC opened this issue Oct 26, 2016 · 8 comments
Open

consul health client timeout #180

EvertMDC opened this issue Oct 26, 2016 · 8 comments

Comments

@EvertMDC
Copy link

Hello,

I have an application that uses consul-client that is running fine on docker 1.11.2.
When deploying the same container to a docker with version 1.12 I get the message that it cannot connect tot the ipv6 address of localhost, which is normal because consul is running on ipv4 localhost.

com.orbitz.consul.ConsulException: Consul request failed
    at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:49)
    at com.orbitz.consul.HealthClient.getChecksByState(HealthClient.java:241)
    at com.orbitz.consul.HealthClient.getChecksByState(HealthClient.java:225)
    at test.consul.ConsulBasedApplicationManager$Updater.run(ConsulBasedApplicationManager.java:85)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:8500
    at com.orbitz.okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:142)
    at com.orbitz.okhttp3.internal.io.RealConnection.connect(RealConnection.java:111)
    at com.orbitz.okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188)
    at com.orbitz.okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127)
    at com.orbitz.okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
    at com.orbitz.okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:289)
    at com.orbitz.okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
    at com.orbitz.okhttp3.RealCall.getResponse(RealCall.java:240)
    at com.orbitz.okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
    at com.orbitz.okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
    at com.orbitz.okhttp3.RealCall.execute(RealCall.java:57)
    at com.orbitz.retrofit.OkHttpCall.execute(OkHttpCall.java:174)
    at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:47)
    ... 4 more

When changing
consul = Consul.builder().build();
to
consul = Consul.builder().withUrl("http://127.0.0.1:8500").build();
one would assume it would take the correct address. Unfortunately this gives a timeout.

com.orbitz.consul.ConsulException: Consul request failed
    at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:49)
    at com.orbitz.consul.HealthClient.getChecksByState(HealthClient.java:241)
    at com.orbitz.consul.HealthClient.getChecksByState(HealthClient.java:225)
    at test.consul.ConsulBasedApplicationManager$Updater.run(ConsulBasedApplicationManager.java:85)
    at java.lang.Thread.run(Thread.java:745)
Caused by: 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.execute(RealCall.java:57)
    at com.orbitz.retrofit.OkHttpCall.execute(OkHttpCall.java:174)
    at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:47)
    ... 4 more
Caused by: java.net.SocketException: Socket closed
    at java.net.SocketInputStream.read(SocketInputStream.java:203)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at com.orbitz.okio.Okio$2.read(Okio.java:139)
    at com.orbitz.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
    ... 19 more

Is this an issue with the way the client connects to consul? Why is it trying to connect to ipv6?

@rickfast
Copy link
Owner

Are you running your app container with --net=host? Otherwise localhost isn't going to work.

@EvertMDC
Copy link
Author

EvertMDC commented Nov 2, 2016

There is a consul agent running inside the container so once the container starts up it registers its service. A curl inside the container to localhost works.

@rickfast
Copy link
Owner

rickfast commented Nov 3, 2016

Not sure what's going on here. I can't reproduce this. I'll look at the OK HTTP docs, but the Consuk code itself doesn't use IPv6

@EvertMDC
Copy link
Author

Can I help you with some additional information maybe?

@rickfast
Copy link
Owner

if you have more information to give, please do.

@curena
Copy link

curena commented Apr 26, 2017

Was this ever resolved? I'm having the same problem, would like to know if there's a workaround.

@EvertMDC
Copy link
Author

Unfortunately not. This is the oldest item on my todo list but I'm not really sure where I could find more info.

@khaosans
Copy link

khaosans commented May 18, 2017

I am also running into this same issue with a dockerized consul agent running on the same host.

edit: I figured out this issue and it had nothing to do with the library. I have the orbitz client running within my dockerized container. Everything is working as expected 👍

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

4 participants