I am using this simple example from the official documentation (I added error checking) and I immediately receive the error: failed to connect to any of the specified hosts
cluster, err := gocb.Connect("couchbase://localhost")
if err != nil {
return nil, err
}
cluster.Authenticate(gocb.PasswordAuthenticator{
Username: "u",
Password: "p",
})
bucket, err := cluster.OpenBucket("beer-sample", "")
if err != nil {
fmt.Println(gocb.ErrorCause(err))
return nil, err
}
I traced the error back to the OpenBucket call. Is anyone else experience this?
brett19
December 19, 2017, 11:41pm
2
Hey @zbecker10 ,
Keep in mind that PasswordAuthenticator is only useable with Couchbase Server 5.0. Can you confirm which server version you are using, and your network layout?
Cheers, Brett
@brett19 , I am using Couchbase Server 5.0 through the downloadable OS X application!
I just simply opened the application, created a new cluster, set the administration username and password and used a sample bucket.
Hi @zbecker10 , the openBucket function assigns bucket name as username. Set the username as ‘beer-sample’ and use following code. it should work.
cluster, err := gocb.Connect("couchbase://localhost")
if err != nil {
return nil, err
}
bucket, err := cluster.OpenBucket("beer-sample", "****")
if err != nil {
fmt.Println(gocb.ErrorCause(err))
return nil, err
}