Couchbase java client not initialize the Cluster object when multiple containers are are running in localhost

HI,

I started three docker containers in localhost using the steps in - Install Couchbase Server Using Docker | Couchbase Docs
The cluster got created successfully.
Now when I try to connect to this cluster using java sdk connection string - localhost:8091
but it does not initializes successfully.
Below is the log-

WARNING: [com.couchbase.endpoint][EndpointConnectionFailedEvent][10s] Connect attempt 1 failed because of TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured) {"circuitBreaker":"DISABLED","coreId":"0x52720f6000000001","remote":"172.17.0.3:11210","type":"KV"}
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)
WARNING: [com.couchbase.endpoint][EndpointConnectionFailedEvent][10s] Connect attempt 1 failed because of TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured) {"circuitBreaker":"DISABLED","coreId":"0x52720f6000000001","remote":"172.17.0.4:11210","type":"KV"}
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)

WARNING: [com.couchbase.endpoint][EndpointConnectionFailedEvent][10s] Connect attempt 1 failed because of : connection timed out: /172.17.0.5:11210 - Check server ports and cluster encryption setting. {"circuitBreaker":"DISABLED","coreId":"0x52720f6000000001","remote":"172.17.0.5:11210","type":"KV"}
com.couchbase.client.core.endpoint.BaseEndpoint$2: connection timed out: /172.17.0.5:11210 - Check server ports and cluster encryption setting.

Exception in thread "main" com.couchbase.client.core.error.UnambiguousTimeoutException: WaitUntilReady timed out {"checkedServices":
["SEARCH","QUERY","MANAGER"],"currentState":"OFFLINE","desiredState":"ONLINE","services":{"search":[{"lastConnectAttemptFailure":"connection timed out: /172.17.0.3:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.3:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.4:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.4:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"},{"lastConnectAttemptFailure":"connection timed out: /172.17.0.5:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.5:8094 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"}],"query":[{"lastConnectAttemptFailure":"Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)","state":"connecting","circuit_breaker_state":"disabled"},{"lastConnectAttemptFailure":"Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"},{"lastConnectAttemptFailure":"connection timed out: /172.17.0.4:8093 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.4:8093 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"},{"lastConnectAttemptFailure":"Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.5:8093 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"state":"connecting","circuit_breaker_state":"disabled"}],"kv":[{"lastConnectAttemptFailure":"connection timed out: /172.17.0.3:11210 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.4:11210 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"},
{"lastConnectAttemptFailure":"connection timed out: /172.17.0.5:11210 - Check server ports and cluster encryption setting.","state":"connecting","circuit_breaker_state":"disabled"}]},"state":{"current_stage":"PING","current_stage_since_ms":29696,"timings_ms":{"CONFIG_LOAD":324},"total_ms":30020},"timeoutMs":30000}

Please suggest the changes needed to make it work.

Hi @anil.kumarsharma10, welcome! Sorry for the delay in getting back to you, I had the draft written and forgot to hit send!

It looks like your client is most likely unable to communicate with the individual containers within your Docker network. Even though your initial connection is going to localhost:8091, the Couchbase cluster is responding with the IP addresses and ports that it is listening on (172.17.0.x) which don’t appear to be on the same network as your client is on.

The best option would be to run your application from within another container on the same docker network. If you want to run your application from outside of the docker network, we recommend only using a single node.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.