To get the ClusterInfo, couchbase always uses the first ip from the list of configured hosts.
If this is not available a ConnectTimeoutException is thrown.
Looks like a bug to me.
After some debugging, it looks like the java couchbase sdk cannot make a initial connection, if the node with the first ip in the configuration is not available.
Many applications need to access com.couchbase.client.java.cluster.ClusterInfo
spring needs this, for example, to create the CouchbaseTemplate.
To get the ClusterInfo you need to call com.couchbase.client.java.Cluster#clusterManager
Only the first host from the connection string is used.
When this first host is not available you get an exception
ConnectTimeoutException: connection timed out: /126.96.36.199:8091
In the exception message you can also see that the first host name was used.
So it does just not work as expected.
The above is true, only for the access to the ClusterInfo
When connecting to buckets, couchbase client correctly iterates over the list of ips, tries to connect to the node, and uses the first successful connection.
In this thread, it was stated, that couchbase would iterate over the ips in reverse order. I think that is not true.
Instead java.util.Collections#shuffle(java.util.List<?>) is used to bring the ips in a random order.
However, this shuffle does not change the order of the original connection string. So the access to ClusterInfo always used the first ip from the configuration.
I am using couchbase java client 2.2.8