Http connection refused error with Consul client
I am using consul client version 1.2.0 in my application. Often I keep seeing connection issue between the Consul client and the local Consul agent/cluster.
Caused by: com.orbitz.consul.ConsulException: Consul request failed at com.orbitz.consul.util.Http.executeCall(Http.java:51) at com.orbitz.consul.util.Http.extract(Http.java:30) at com.orbitz.consul.CatalogClient.getDatacenters(CatalogClient.java:47)
Caused by: java.net.ConnectException: Failed to connect to localhost:8501 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113) Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
I have verified that the local Consul agent/cluster is up and listening on port 8501. The error sometimes disappears on retries and sometimes I need to reboot my application i.e. destroy the JVM and restart the server to make the problem go away. No changes are made on the Consul itself.
- Is there any ways to have additional logging for the Http trace or traffic to debug this issue?
- Are there APIs available to set more Http configurations like ConnectionPool min/max limit, idle timeout etc?