How to connect to multiple couchbase server URLs?


#1

In the gocb.Connect() API call:

func Connect(connSpecStr string) (*Cluster, error)

Connect creates a new Cluster object for a specific cluster.

Is there any docs on what the connSpecStr should look like when trying to pass multiple couchbase server URLs?


#2

Hi @traun,

You can also specify multiple hosts in the connection string by separating each host with a comma:

cluster, err := gocb.Connect("couchbase://host1,host2,host3,hostN")

Specifying multiple hosts may add additional redundancy when bootstrapping.

From Managing Connections.


#3

Thanks @jkurtz!

Is it possible to use the couchbase:// format on non-standard ports? For example, if map port 28091 is mapped to port 8091, is it possible to connect via this syntax?


#4

From looking at https://github.com/couchbaselabs/gocbconnstr, looks like non-standard ports are supported