Cannot scope.Query() -- ambiguous timeout error

I am trying to upgrade to the new Go SDK while also migrating to a scopes and collections model for multi-tenancy. The Go SDK upgrade seems successful – I can call CB 6.6 successfully using cluster.Query(). However, when calling CB7 and trying to use scope.Query(), I only get ambiguous timeout errors. In both cases, timeout options are set at the cluster level:

	// Connect the SDK to Couchbase Server.
	timeConfig := gocb.TimeoutsConfig{
		ConnectTimeout: (time.Duration(config.CBConnTimeout * 1000)) * time.Millisecond,
		KVTimeout:      (time.Duration(config.CBKVTimeout * 1000)) * time.Millisecond,
		QueryTimeout:   (time.Duration(config.CBOpTimeout * 1000)) * time.Millisecond,
	clusterOpts := gocb.ClusterOptions{
		Authenticator: gocb.PasswordAuthenticator{
			Username: config.CBUser,
			Password: config.SQLPwd,
		TimeoutsConfig: timeConfig,
	myCB, err = gocb.Connect(config.CBURL, clusterOpts)
	if err != nil {
		log.Fatalln("InitCB:", err)

I have tried setting the Timeout property of scope.Query(), but without success:

	opts := &gocb.QueryOptions{}
	if len(holders) > 0 {
		opts.PositionalParameters = holders
	opts.Timeout = (time.Duration(config.CBOpTimeout * 1000)) * time.Millisecond

	rowSet, err = myCBScope.Query(queryStr, opts)
	if err != nil {
		log.Println(logName, err)
		return cbytes, err

Hi @bhouse1273, first to note that 1000ms is quite a short timeout for query - the SDK default is 75s. You could try enabling logging (Collecting Information & Logging | Couchbase Docs) and see if anything obvious appears there. If you’re still stuck then if you can post up the log and the full error object (log.Fatalf("%v", err) should do it) then I can take a look.

FWIW, it turns out that this was a connectivity issue, not a code issue, but I think your advice is valuable nonetheless. I’ll be looking into that. :slight_smile: