I am wondering what the best way is to check in .NET if a Bucket is still open / active. I have a .NET app which up on start is initializing and creating a connection to the couchbase server and returning a the bucket object. My code then uses the bucket object to make upserts or N1QL calls. To make it more stable i want to check if the connection is still open before i try upserts or N1Ql query’s. I found i could check to see if my bucket is open via bucket.Cluster.IsOpen('myBucketName") which will return a true if its open or false if not. Is that the best aproach or is there a better way ?
Have a look at the API reference for the
diagnostics. Ping in particular is useful if you have reason to suspect a connection could have gone half-open (e.g., client sees it as ESTABLISHED and cluster side sees it as terminated). There are some details there.
If your use case is rather at startup time, you should just see higher latency and SDK 3.0 (in beta as of this writing) has a
waitUntilReady kind of method after creating a