Error connecting to cluster with 3.1.7.0 (clr/.NET 5.0.4)

I am having a problem connecting to cluster running in docker on a local network.
I am able to connect to cluster with management interface.
I’ve mapped all the ports:

 0.0.0.0:11210 11210/tcp
0.0.0.0:11211 11211/tcp
0.0.0.0:8091 8091/tcp
0.0.0.0:8092 8092/tcp
0.0.0.0:8093 8093/tcp
0.0.0.0:8094 8094/tcp
0.0.0.0:8095 8095/tcp
0.0.0.0:9140 9140/tcp 

Connection code:

let GetBuckets conf (logger:ILogger) =
    async {

        // todo:
        // let nodes = conf.GetSection("Servers")

        logger.LogInformation "Connecting to cluster..."
        let! cluster = Async.AwaitTask <| Cluster.ConnectAsync("couchbase://192.168.1.248","webuser","p4ssw0rd")

        let! ping = Async.AwaitTask <| cluster.PingAsync()

        logger.LogInformation ping.Sdk

        ping.Services 
        |> Seq.iter (fun s -> logger.LogInformation s.Key)
        

        logger.LogInformation "Connecting to bucket..."
        return! Async.AwaitTask <| cluster.Buckets.GetAllBucketsAsync()

    } |> Async.RunSynchronously

Temporarely as I am trying to get this to work webuser is granted fulladmin

The exception:

[19:32:48] info: [0] Connecting to cluster...
[19:32:59] info: [0] couchbase-net-sdk/3.1.7.0 (clr/.NET 5.0.4) (os/Microsoft Windows 10.0.19043)
[19:32:59] info: [0] Connecting to bucket...
Application startup exception: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Couchbase.Core.ServiceUriProvider.GetRandomManagementUri()
   at Couchbase.Management.Buckets.BucketManager.GetUri(String bucketName)
   at Couchbase.Management.Buckets.BucketManager.GetAllBucketsAsync(GetAllBucketsOptions options)
   --- End of inner exception stack trace ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 337   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 870
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 878
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1142
   at Program.GetBuckets[a](a conf, ILogger logger) in D:\active_projects\pindap\pindap\server\api\matter\Program.fs:line 39
   at Program.Startup.Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory) in D:\active_projects\pindap\pindap\server\api\matter\Program.fs:line 76
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
[19:33:03] crit: Microsoft.AspNetCore.Hosting.WebHost[6] Application startup exception System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)  ---> System.NullReferenceException: Object reference not set to an instance of an object.    at Couchbase.Core.ServiceUriProvider.GetRandomManagementUri()    at Couchbase.Management.Buckets.BucketManager.GetUri(String bucketName)    at Couchbase.Management.Buckets.BucketManager.GetAllBucketsAsync(GetAllBucketsOptions options)    --- End of inner exception stack trace ---    at Microsoft.FSharp.Control.AsyncResult`1.Commit() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 337    at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 870    at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 878    at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1142    at Program.GetBuckets[a](a conf, ILogger logger) in D:\active_projects\pindap\pindap\server\api\matter\Program.fs:line 39    at Program.Startup.Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory) in D:\active_projects\pindap\pindap\server\api\matter\Program.fs:line 76    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)    at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)    at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()

Other observations:
If I use incorrect password, it fails immediately. When using correct password it pauses for a while after:

[19:32:48] info: [0] Connecting to cluster...

before showing the rest of the result.

How can I resolve this?
Thank you.

Ignore everything above, it appears to be a mis-configured cluster. Similar thing was happening with node.js sdk, so I went to look at some documents in detail and saw a bunch of errors.

Deleted and re-created the cluster.
The above code works now.

Edit:
Is this a result of stopping/starting docker containers and having data corruption? Does docker shut down couchbase gracefully?

1 Like