java.net.ConnectException : connection refused for com.couchbase.client.core.endpoint.Endpoint

Hi All,

I have a web application which uses CB java client to connect to a couchbase cluster. Through the client I pass the connection information by creating a CouchbaseEnvironment etc as below:

@Bean
public CouchbaseEnvironment couchbaseEnvironment() {
return DefaultCouchbaseEnvironment
.builder()
.connectTimeout(connectTimeout)
.dnsSrvEnabled(true)
.build();
}

@Bean(destroyMethod = "disconnect")
public Cluster cluster() {
	return CouchbaseCluster.create(couchbaseEnvironment(),seedNode);
}

@Bean(destroyMethod = "close")
public Bucket bucket() {	
	return cluster().openBucket(bucketName, bucketPassword, bucketTimeOut, TimeUnit.MILLISECONDS);
}

@Bean CacheBuilder cacheBuilder(){
	return CacheBuilder.newInstance(bucket());
}

@Bean
public CacheManager cacheManager(){
	return new CouchbaseCacheManager(cacheBuilder(),caches());
}

My dependencies look like this:

org.springframework.data spring-data-couchbase 2.1.2.RELEASE com.couchbase.client java-client 2.3.6 com.couchbase.client couchbase-spring-cache 2.0.0

When I start the web application, I can see through the application log that with the information provided through Java SDK, the client is able to connect to the cluster nodes and open the bucket as below:

2016-12-19 12:40:59,560 [cb-io-1-1] INFO com.couchbase.client.core.node.Node - Connected to Node 10.100.30.104
2016-12-19 12:40:59,560 [cb-io-1-1] INFO com.couchbase.client.core.node.Node - Connected to Node 10.100.30.104
2016-12-19 12:40:59,572 [cb-io-1-2] INFO com.couchbase.client.core.node.Node - Connected to Node 10.100.30.105
2016-12-19 12:40:59,572 [cb-io-1-2] INFO com.couchbase.client.core.node.Node - Connected to Node 10.100.30.105
2016-12-19 12:41:00,205 [cb-computations-3] INFO com.couchbase.client.core.config.ConfigurationProvider - Opened bucket default
2016-12-19 12:41:00,205 [cb-computations-3] INFO com.couchbase.client.core.config.ConfigurationProvider - Opened bucket default

If I’m correct, this is the first step of the bootstrap process to connect to the CB cluster. Then what happens is as below:

2016-12-19 12:41:00,872 [cb-io-1-1] WARN com.couchbase.client.core.endpoint.Endpoint - [my_second_CB_node/XX.YYY.ZZ.105:8092][ViewEndpoint]: Could not connect to remote socket.
2016-12-19 12:41:00,872 [cb-io-1-1] WARN com.couchbase.client.core.endpoint.Endpoint - [my_second_CB_node/XX.YYY.ZZ.105:8092][ViewEndpoint]: Could not connect to remote socket.
2016-12-19 12:41:00,873 [localhost-startStop-1] WARN org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.aspectj.AspectJCachingConfiguration’: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘cacheManager’ defined in com.nuvizz.cache.config.CouchbaseCacheConfiguration: Invocation of init method failed; nested exception is com.couchbase.client.core.RequestCancelledException: Request cancelled in-flight.
2016-12-19 12:41:00,875 [cb-io-1-1] WARN com.couchbase.client.core.endpoint.Endpoint - Error during reconnect:
java.net.ConnectException: Connection refused: my_second_CB_node/XX.YYY.ZZ.105:8092
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:712)
at com.couchbase.client.deps.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:223)
at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:285)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:589)

at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:513)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:427)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:399)
at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)

I’m passing comma separated IP addresses of the CB cluster nodes to the client. I tried changing the order of the nodes provided to the Java client, but either case the stack trace show me the IP address of the second node whose port 8092 is rejecting socket connection.

What am I missing here?

Please help me out.

Just to update on this.

I was trying this on a Centos platform and got this issue. Later I tried the same on a ubuntu based CB cluster and it worked flawlessly. Looks like the issue that I’m facing is related to the more restrictive nature of Centos.

Thanks
Sethukumar