Is it possible to connect to a couchbase cluster instead of a specific node?

var cluster = new Cluster(new ClientConfiguration
{
Servers = new List { new Uri(“http://releasetest1”) }
});

is what I currently do, I have a test cluster with 4 nodes (2 windows 2 linux) I have 3 nodes running couchbase 6.5 (the last one will be upgraded today) it’s running 5.1)

is it possible to use the cluster name and let couchbase decide which node to access? This way I could take a node down and not worry about the app breaking

otherwise, I’ll store the node to access somewhere and read it that way I can just change the data without having to rebuild the solution

thanks

dougc

@dougc

Due to the nature of Couchbase’s architecture, connecting to a cluster always connects to all nodes in the cluster. The list of servers you’re providing for bootstrap is just a list of possible options that the SDK can use to start the process. It randomly tries one, and once successful throws away the list and connects to all the nodes returned from the server. The reason for having a list of nodes is simply for redundancy if a node is down during bootstrap.

Brant

2 Likes

Well @btburnett3 beat me to another answer :slight_smile:

But as an alternative to listing URLs, I will plug some of Brant’s work and say that you can use DNS SRV as another option (see Brant’s post here: Using DNS SRV to connect to Couchbase in .NET Core - RandomDev, the .NET extension here: Couchbase.Extensions/docs/dns-srv.md at master · couchbaselabs/Couchbase.Extensions · GitHub and it’s especially helpful if you happened to be using Kubernetes: ASP.NET Core Kubernetes Tutorial for AKS - The Couchbase Blog)

2 Likes

thanks for the response, so I could pass in ALL the nodes in my cluster and it would keep trying till one worked or they all failed?

1 Like

I will certainly look into this

thanks

@dougc

Yes, that’s the recommended best practice.