Cannot perform operations on a shutdown bucket

In my rest API server , I have a singleton class that mange my database , In app startup , I create the singleton object and create a cluster.openBucket('bucketname'); , So openBucket called once and only once and In each instance of my application , only one openBucket called at startup and I use returned object in whole application

In my experience , I see when as startup and openBucket call , I have no network connection to database , we have Cannot perform operations on a shutdown bucket error , It’s ok , no problem

But when network comes back , I see that still we have Cannot perform operations on a shutdown bucket error and I must restart my application to solve issue

  1. Is my approach wrong? I openBucket at startup and use the returned object in whole app
  2. How can I have a safe opened bucket? while we have no issue , without restarting app it must works

Hey @socketman2016,

Unfortunately this is an inherent difficulty with the 2.x class of SDK clients. The 3.x clients which should have a DP release in the near future will adjust this such that the behaviour during connection is more aligned with the behaviour after a connection is established, and the client will persist in attempting to obtain a working connection to Couchbase. In the meantime, a possible solution would be to automatically replace the bucket instance after the openBucket call fails. You can implement this by looking for an error in the openBucket callback and retrying.

Cheers, Brett

Ok , I can catch error at opening bucket and retry to open it again
What if in startup I open bucked successfully , later we have network issue ?
Is there any event that let me to retry?

Hey @socketman2016,

The case of having network issues after a successful open, the client will automatically re-establish the connection as soon as possible. The failing call and permanency of that only occurs during the initial connection, and this is what has changed in 3.0 to adopt something a little more consistent.

Cheers, Brett

@brett19 I still having issue after years, I am using CB server 6.6 and Nodejs sdk 3.1.1
If get the error parent cluster object has been closed once , i.e we open a when once the couchbase is down
It never fixed and all subsequent request get the error even the couchbase is up
We must restart application