Unable to Bootstrap

I am having an issue connecting to CouchBase from a .NET 4.8 Web Api project. The exact same code (same code file actually as it is in a shared library) works for an ASP.NET 4.8 Web Forms project.

In the Web Api I get this error: Cluster level WaitUntilReady is only supported by Couchbase Server 6.5 or greater.

If found this Post. I have gone through the dependencies in both projects and all that they share are on the same version and the same assembly binding settings. Lastly, I have added the dependencies listed in the migration doc and made sure the assembly bindings were added.

Any ideas would would be greatly appreciated.

Hi @BrianR72

If your on server version less than 6.5, that error means your trying to use a feature (Cluster.WaitUntilReady) not supported on that server version, however, you still use the bucket level WaitUntilReady. Just skip the cluster level WaitUntilReady call, and open a bucket and call WaitUntilReady on it.

If that is not the case, then for some reason the SDK cannot bootstrap against the cluster for whatever reason. The easiest way to resolve is find the root cause by enabling logging and then diagnosing the logs to determine why bootstrapping did not happen.

A typical reason for this is because the remote host isn’t reachable from the App environment because a port isn’t open, but there are lots of reasons.

Jeff

Hi Brian,

try Dotnet core web API with latest SDK. the sample code is below


 static async Task Main(string[] args)
        {

            IServiceCollection serviceCollection = new ServiceCollection();
            serviceCollection.AddLogging(builder => builder
                .AddFilter(level => level >= LogLevel.Debug)
            );
            var loggerFactory = serviceCollection.BuildServiceProvider().GetService<ILoggerFactory>();
            loggerFactory.AddFile("C:\\Users\\User name\\Documents\\Logs\\myapp-{Date}.txt", LogLevel.Debug);


            // get a bucket reference
            var endpoint = "public dns.eastus.cloudapp.azure.com"; // you may try ip
            var bucketName = "travel-sample";
            var username = "username with application access for bucket";
            var password = "password";
            // User Input ends here.

            var opts = new ClusterOptions().WithCredentials(username, password).WithLogging(loggerFactory); 
            // opts = opts.WithLogging(loggerFactory);
            opts.HttpIgnoreRemoteCertificateMismatch = true;
            opts.KvIgnoreRemoteCertificateNameMismatch = true;

            var cluster = await Cluster.ConnectAsync("http://" + endpoint, opts); // change from couchbase to http
            var bucket = await cluster.BucketAsync(bucketName);
            var collection = bucket.DefaultCollection();

            // Insert Document
            var InsertResult = await collection.InsertAsync("MyDoc_15", new {  id="15",type="Mobile",name="Nokia",iata="Q5",icao="MLA",callsign="Caller",country="India"});

            //Update Doc
            var UpsertResult = await collection.UpsertAsync("airline_10", new {  id="10",type="Mobile",name="Nokia",iata="Q5",icao="MLA",callsign="Caller",country="India"});

            //Delete Doc
            await collection.RemoveAsync("airline_10");
            Console.WriteLine("Deleted");


            //Retreive Doc
            var queryResult = await collection.GetAsync("airline_10").ConfigureAwait(false);
            var doc = queryResult.ContentAs<dynamic>();
            Console.WriteLine(doc);


           
           
        }

What logs would I need to upload for you to help diagnose this issue as I am still having this problem.

Once logging is enabled, then just run the code and post the logs generated by the SDK, redacting as/if necessary.

Thank you. Any light you can shed on this would be much appreciated.

I attached the logs from the server logs folder. I am running this in Docker using the latest 7.0.3 image.

logs.zip (1.8 MB)

The text from the log4Net file (level is set to ALL) is:
DEBUG 57 Couchbase.Core.Configuration.Server.ConfigHandler - Waiting for 00:00:02.5000000 before polling.
DEBUG 57 Couchbase.Core.ClusterContext - Bootstrapping with node 127.0.0.1
DEBUG 57 Couchbase.Core.ClusterContext - Attempted bootstrapping on endpoint 127.0.0.1 has failed.
DEBUG 57 Couchbase.Core.Bootstrapping.Bootstrapper - The subject is bootstrapped: True
DEBUG 9 Couchbase.Core.Bootstrapping.Bootstrapper - The subject is bootstrapped: True
DEBUG 85 Couchbase.Core.Configuration.Server.ConfigHandler - Done waiting, polling…
DEBUG 85 Couchbase.Core.Configuration.Server.ConfigHandler - Waiting for 00:00:02.5000000 before polling.
DEBUG 85 Couchbase.Core.Bootstrapping.Bootstrapper - The subject is bootstrapped: True
DEBUG 11 Couchbase.Core.Bootstrapping.Bootstrapper - The subject is bootstrapped: True
DEBUG 44 Couchbase.Core.Configuration.Server.ConfigHandler - Done waiting, polling…
DEBUG 44 Couchbase.Core.Configuration.Server.ConfigHandler - Waiting for 00:00:02.5000000 before polling.
DEBUG 46 Couchbase.Core.Configuration.Server.ConfigHandler - Done waiting, polling…
DEBUG 43 Couchbase.Core.Bootstrapping.Bootstrapper - The subject is bootstrapped: True
DEBUG 46 Couchbase.Core.Configuration.Server.ConfigHandler - Waiting for 00:00:02.5000000 before polling.

The stack trace is:
at Couchbase.Cluster.d__33.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MyNamespace.MyCaching.MyCache.d__41.MoveNext() in My File Location

I don’t see the logs you posted above in the logs.zip. From what you posted:

This indicates your trying to connect to localhost or 127.0.0.1; is Couchbase installed locally? If not that might be your problem.

SDK Doctor can help identify connectivity issues: SDK Doctor | Couchbase Docs

You need to post the entire stacktrace and exception message for it too be useful.

I see the logs.zip as a link to download. If there is a particular log file I can port it. In Visual Studio I will try to get a better stack trace.

What I mean is that logs you posted above are not in the logs.zip…there are completely different SDK logs in there.

I was able to resolve the issue by changing the sample Log4Net code found here.

In the Log function the Exception object must be passed for each logging level otherwise the exception never gets to Log4Net. The sample code only does this for the ‘default’ condition. Thus I was able to get detailed error information.

            switch (logLevel) {
                case LogLevel.Critical:
                    _log.Fatal(message, exception);
                    break;
                case LogLevel.Debug:
                case LogLevel.Trace:
                    _log.Debug(message, exception);
                    break;
                case LogLevel.Error:
                    _log.Error(message, exception);
                    break;
                case LogLevel.Information:
                    _log.Info(message, exception);
                    break;
                case LogLevel.Warning:
                    _log.Warn(message, exception);
                    break;
                default:
                    _log.Warn($"Encountered unknown log level {logLevel}, writing out as Info.");
                    _log.Info(message, exception);
                    break;
            }