Couchbase .Net client 3.1.2.0 NullRef exception

Hello,
I’m trying to connect to Couchbase server version 6.6.0 using latest .net sdk
and see error
System.NullReferenceException: ‘Object reference not set to an instance of an object.’

Server is local on Windows machine.

Example code:

var cluster = await Cluster.ConnectAsync("couchbase://localhost", "User", "123456");
var report = await cluster.PingAsync();

Logs:

There was an error attempting to resolve hosts using DNS-SRV - Non-Existent Domain
Bootstrapping with node localhost
Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01.
Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01.
Starting connection initialization on server [::1]:11210.
Starting connection initialization on server [::1]:11210.
Executing op Helo on [::1]:11210 with key {"i":"9c04414fbaf8e727/0000000000000001","a":"couchbase-net-sdk/3.1.2.0 (clr/.NET Core 3.1.10) (os/Microsoft Windows 10.0.18363)"} and opaque 4.
Executing op Helo on [::1]:11210 with key {"i":"9c04414fbaf8e727/0000000000000002","a":"couchbase-net-sdk/3.1.2.0 (clr/.NET Core 3.1.10) (os/Microsoft Windows 10.0.18363)"} and opaque 3.
Completed executing op [::1]:11210 on Helo with key {"i":"9c04414fbaf8e727/0000000000000001","a":"couchbase-net-sdk/3.1.2.0 (clr/.NET Core 3.1.10) (os/Microsoft Windows 10.0.18363)"} and opaque 4
Completed executing op [::1]:11210 on Helo with key {"i":"9c04414fbaf8e727/0000000000000002","a":"couchbase-net-sdk/3.1.2.0 (clr/.NET Core 3.1.10) (os/Microsoft Windows 10.0.18363)"} and opaque 3
Executing op GetErrorMap on [::1]:11210 with key  and opaque 6.
Executing op GetErrorMap on [::1]:11210 with key  and opaque 8.
Completed executing op [::1]:11210 on GetErrorMap with key  and opaque 8
Completed executing op [::1]:11210 on GetErrorMap with key  and opaque 6
Attempted bootstrapping on endpoint localhost has failed.
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Unknown error (0xc1000001)
   at Internal.Cryptography.HashProviderCng.AppendHashData(ReadOnlySpan`1 source)
   at System.Security.Cryptography.HMACSHA1.HashCore(ReadOnlySpan`1 source)
   at System.Security.Cryptography.HashAlgorithm.TryComputeHash(ReadOnlySpan`1 source, Span`1 destination, Int32& bytesWritten)
   at System.Security.Cryptography.Rfc2898DeriveBytes.Func()
   at System.Security.Cryptography.Rfc2898DeriveBytes.GetBytes(Int32 cb)
   at Couchbase.Core.IO.Authentication.ScramShaMechanism.GetSaltedPassword(String password, Byte[] salt, Int32 iterationCount)
   at Couchbase.Core.IO.Authentication.ScramShaMechanism.AuthenticateAsync(IConnection connection, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.Couchbase.Core.IO.Connections.IConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass29_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpoint endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.BootstrapGlobalAsync()

Hello @shersh sorry for the delay, Just a FYI

I am using 3.1.2 and I am getting the expected output

My environment : Couchbase Server 6.5.1 CE, SDK 3.1.1 , MacOS - Which windows OS are you running it on ?

{"id":"fc390af1-3662-42c4-8921-9380a8c3465c","version":1,"config_rev":26,"sdk":"couchbase-net-sdk/3.1.2.0 (clr/.NET Core 3.1.11) (os/Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64)","services":{"kv":[{"id":"2","state":"ok","local":"[::1]:52158","remote":"[::1]:11210","last_activity_us":43862,"latency_us":274776},{"id":"1","state":"ok","local":"[::1]:52157","remote":"[::1]:11210","last_activity_us":66579,"latency_us":74858}],"n1ql":[{"state":"ok","remote":"[::1]:11210","last_activity_us":0,"latency_us":15231898,"scope":"Cluster"}],"fts":[{"state":"ok","remote":"[::1]:11210","last_activity_us":120700,"latency_us":1744452,"scope":"Cluster"}]}}

I don’t see the NRE in your logs, perhaps that is what is bubbling up from the sdk?

WindowsCryptographicException: Unknown error (0xc1000001)

  • This is an unusual AFAIK - I have never seen it from the SDK itself. Curious what version of Windows and .NET are you running?
  • Is it intermittent or does is happen every time?

-Jeff

1 Like