Bucket with name default does not exist or cannot be reached

The following code works on 3.2.6 but not in 3.2.7. It throws an exception on BucketAsync “Bucket with name default does not exist or cannot be reached”. Any clue what has changed and that is broken now?

private async Task<ICouchbaseCollection> InitializeClusterAsync(String Uri, String Bucket, String Username, String Password) {
            var options = new ClusterOptions() {
                KvTimeout = TimeSpan.FromSeconds(5),
                ManagementTimeout = TimeSpan.FromSeconds(12),
                EnableDnsSrvResolution = false,
                UserName = Username,
                Password = Password,
                EnableTls = false,
                EnableConfigPolling = false,
                MaxKvConnections = 25
            };

            var cluster = await Couchbase.Cluster.ConnectAsync(Uri, options).ConfigureAwait(false);
            //var bucket = await cluster.BucketAsync(Bucket).ConfigureAwait(false);
            var bucket = cluster.BucketAsync(Bucket).ConfigureAwait(false);

            return (bucket.DefaultCollection());
        }

@zissop1

I don’t believe anything has changed there; its more likely that SDK cannot communicate with the server or the bucket indeed doesn’t exist. I would enable logging and then analyze the logs for details on what exactly is happening here.

I am pretty sure this would fail as your calling DefaultCollection() on a Task that has not been awaited.

Jeff

And why 3.2.6 and previous works ok?

It is called like below

private async Task<ICouchbaseCollection> InitializeClusterAsync(String Uri, String Bucket, String Username, String Password) {
            var options = new ClusterOptions() {
                KvTimeout = TimeSpan.FromSeconds(5),
                ManagementTimeout = TimeSpan.FromSeconds(12),
                EnableDnsSrvResolution = false,
                UserName = Username,
                Password = Password,
                EnableTls = false,
                EnableConfigPolling = false,
                MaxKvConnections = 25
            };

            var cluster = await Couchbase.Cluster.ConnectAsync(Uri, options).ConfigureAwait(false);
            var bucket = await cluster.BucketAsync(Bucket).ConfigureAwait(false);

            return (bucket.DefaultCollection());
        }

        public ICouchbaseCollection GetCouchbaseCollection(String Uri, String Bucket, String Username, String Password) {
            _gcollection = InitializeClusterAsync(Uri, Bucket, Username, Password).GetAwaiter().GetResult();
            return (_gcollection);
        }

Never mind, version 3.2.8 fixed the problem.

@zissop1

Good to hear its resolved for you.

I noticed that EnableConfigPolling is disabled (false) in ClusterOptions; I wouldn’t suggest disabling it as it proactively checks for cluster config changes. In a single node deployment this likely isn’t a problem, but if your cluster contains more than one node there may be a delay if the topology changes.

Jeff