Couchbase .Net SDK error - "Could not bootstrap"

.net
connections
server
sdk

#1

I am trying to connect to my couchbase server (Enterprise ver 4.6.2) and open a bucket using the .Net SDK, the code is very simple but still fail to work:

    var cluster = new Cluster(new ClientConfiguration
    {
        Servers = new List<Uri> { new Uri("https://10.0.0.54:8091/") }
    });

    try
    {
        var bucket = cluster.OpenBucket("default");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error getting bucket.");
        Console.WriteLine(ex.Message);
    }

The inner exception details I get:

Message

Object reference not set to an instance of an object

StackTrace

Couchbase.IO.Services.PooledIOService.CheckEnabledServerFeatures(IConnection connection)
   at Couchbase.IO.Services.PooledIOService..ctor(IConnectionPool connectionPool)
   at Couchbase.IO.IOServiceFactory.<>c__DisplayClass0_0.<GetFactory>b__0(IConnectionPool pool)
   at Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String username, String password)

The main exception I see is:

Could not bootstrap - check inner exceptions for details.

And the stack trace:

   at Couchbase.Core.ClusterController.CreateBucket(String bucketName, String username, String password, IAuthenticator authenticator)
   at Couchbase.Core.ClusterController.CreateBucket(String bucketName, IAuthenticator authenticator)
   at Couchbase.Cluster.OpenBucket(String bucketname)
   at Couchbase.Program.Main(String[] args)

Any idea what the issue is?


#2

Hi @ido -

Bootstrapping errors mean that the client cannot connect to the remote cluster or that the bucket does exist or that an auth error occurred. FWIW I cut and pasted your code, changing the IP to my cluster, and was able to connect.

Can you post the entire exception and stacktrace? Also, check to see if you can connect to the server using your browser. Finally, which SDK version are you using?

-Jeff


#3

Hey Jeff,

I am using version 2.4.8.0 (SDK), its the latest one from Nuget.

I am able to connect from my browser and also run certain requests from Fiddler.

I installed Couchbase locally and it works well, but when trying to connect to my AWS instance (I used couchbase’s AMI on AWS Marketplace) it doesnt work.

Just to make it clear, from the browser and Fiddler, my AWS instance is accessible, but not from the code above. I checked the security groups and its all set well, so no issue there.

I also dont see any fiddler traffic when debugging the code…

Any idea?


#4

@ido

I need more diagnostic information to determine what the problem is, can you:

  • Post the entire stacktrace

  • Enable logging and post the results during the bootstrapping process

Also I suggest you:

  • Run SDK Doctor against the cluster and see what it uncovers.

  • Read through this and make sure you have the correct port publicly exposed.

-Jeff


#5

I’m having the exact same problem. I can connect through the UI just fine and run queries in the browser but the SDK won’t connect. I’m using the same code (from the tutorial on the site) and getting the same error. I ran sdk-doctor and it gave me:

[WARN] Your connection string specifies only a single host. You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
[ERRO] Failed to fetch configuration via cccp from 127.0.0.1:11210 (error: EOF)
[ERRO] Failed to fetch terse configuration via http from 127.0.0.1:8091 (error: http error (status code: 404))
[ERRO] All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible

In case it was a binding issue, I tried both localhost and 127.0.0.1 with the same result.

I’m running from the couchbase docker image using the example run command


#6

I figured it out almost as soon as I posted so I’ll share in case it helps.

  • Part of it was a binding issue. The server was listening for 127.0.0.1 not localhost. For some reason sdk-doctor failed on both. I suspect it was related to the other issue of the bucket not existing.
  • Coming from MongoDB, we’re used to the SDK automatically creating the database and/or collection if they don’t exist. Apparently that’s not how this one works. default did not exist, thus the error. I created it by hand in the UI and tried again and it worked.
  • In reading further down the docs for the docker image, it turns out that I was supposed to be connecting not to http://127.0.0.1:8091, but http://127.0.0.1:8091/pools instead

#7

I’m having a similar issue (connection refused), and am running in Kubernetes, but I’m unable to resolve it using the fixes suggested here.