Are there any best practices on how to open couchbase cluster and bucket?
Currently we opening cluster and bucket in application startup:
CouchbaseEnvironment environment = DefaultCouchbaseEnvironment.builder().autoreleaseAfter(AUTO_RELEASE_AFTER).build(); Cluster cluster = CouchbaseCluster.create(environment, this.couchbaseConfig.getUrl()); cluster.authenticate(this.couchbaseConfig.getUsername(), this.couchbaseConfig.getPassword()); Bucket bucket = cluster.openBucket(bucketName);
But when the couchbase server is stopped and started, it attempts to reconnect with the endpoint and searches for the bucket. It successfully finds the bucket and gets connected to it and we also receive logs which indicate that the bucket has been connected to. All of this happens automatically on its own.
Now, the problem we are facing is, even after the connection to bucket is established and the bucket has opened, when any of the service endpoint is hit, it is not able to perform any couchbase operations.
So the problem is with the cluster and not the bucket connection. Is there any best practice to open bucket and cluster on startup of the application so that the services need not be restarted every time the couchbase server is down and up again?