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.
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.
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 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;
}