No available N1QL nodes error


Trying out the new SDK. Normal GET/INSERT op works but i cant get the N1QL Execution to work. The CLI cbq works as normal with N1QL queries on my cluster. I have also tried various connection strings/IP on ports on the connect method.

Searched the net and the nodejs SDK seems to have a “enable” method on buckets to enable n1ql nodes. For some reason the N1qlEps() in the agent packages failes to find any nodes or am i missing something (see a simple test below)?

package main

import (

func main() {

cluster, err := gocb.Connect("couchbase://localhost:8091/")
if err != nil {
	log.Fatalf("Error connecting:  %v", err)

users, err := cluster.OpenBucket("activity", "")
if err != nil {
	log.Fatalf("Error open bucket:  %v", err)

var dummy interface{}
users.Get("icamovie_98392", &dummy)

query := gocb.NewN1qlQuery("SELECT * FROM activity")

rows, err := users.ExecuteN1qlQuery(query, nil)
if err != nil {

var row interface{}
for rows.Next(&row) {
	fmt.Printf("Row: %+v\n", row)

Hey Lundin,

What version of Couchbase Server are you using? The support for N1QL inside the Go SDK works only with Couchbase Server 4.0 which has N1QL integrated in the overall Server Package.

Cheers, Brett

Hi Brett!

Thanks for the reply, and nice work with the SDK!
The version is indeed 4.0, v.4.0.0-4047 on both machines. I have created the indexes using cbq tool
Definition: CREATE PRIMARY INDEX #primary ON activity USING GSI
Definition: CREATE INDEX subjectsid ON activity(subject_id) USING GSI

The panic msg is below as well as the error message.
No available N1QL nodes.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x28 pc=0x260c]

goroutine 1 [running]:
/Users/pontus/Applications/exchange/src/exchangeapp/workers/couchdbtest.go:36 +0x60c

goroutine 11 [select]:
/usr/local/go/src/net/http/transport.go:928 +0x9ce
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 13 [chan receive]:·006()
/Users/pontus/Applications/exchange/src/ +0x56
created by*Agent).httpLooper
/Users/pontus/Applications/exchange/src/ +0xed3

goroutine 8 [IO wait]:
net.(*pollDesc).Wait(0xc208010140, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc208010140, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc2080100e0, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x598b20, 0xc20800b310)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc208038018, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc
net/http.noteEOFReader.Read(0x59a008, 0xc208038018, 0xc208080058, 0xc20807e000, 0x1000, 0x1000, 0xd9, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc20801e0c0, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
:125 +0xd4
/usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).ReadSlice(0xc2080524e0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:295 +0x257
net/http/internal.readLine(0xc2080524e0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:110 +0x5a
/usr/local/go/src/net/http/internal/chunked.go:47 +0x46
net/http/internal.(*chunkedReader).Read(0xc20803ae70, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:77 +0xbb
net/http.(*body).readLocked(0xc208030280, 0xc208078004, 0xdfc, 0xdfc, 0xffffffff, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:584 +0x7a
net/http.(*body).Read(0xc208030280, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:579 +0x115
net/http.(*bodyEOFSignal).Read(0xc208030300, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1193 +0x285
encoding/json.(*Decoder).readValue(0xc20806e000, 0xb026b, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:124 +0x5e1
encoding/json.(*Decoder).Decode(0xc20806e000, 0x2caa00, 0xc20801e580, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:44 +0x7b*Agent).httpLooper(0xc208011c70, 0xc20801e9a0)
/Users/pontus/Applications/exchange/src/ +0xff7
created by*Agent).connect
/Users/pontus/Applications/exchange/src/ +0xa99

goroutine 12 [select]:
/usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 15 [select]:*memdPipeline).ioLoop(0xc20807c100)
/Users/pontus/Applications/exchange/src/ +0x2e1*memdPipeline).Run(0xc20807c100)
/Users/pontus/Applications/exchange/src/ +0x5e
created by*Agent).connectPipeline
/Users/pontus/Applications/exchange/src/ +0x34f

goroutine 16 [IO wait]:
net.(*pollDesc).Wait(0xc2080103e0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc2080103e0, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc208010380, 0xc208056000, 0x1000, 0x1000, 0x0, 0x598b20, 0xc20800b070)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc2080380c8, 0xc208056000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc*memdConn).readBuffered(0xc20803acc0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/pontus/Applications/exchange/src/ +0x326*memdConn).ReadPacket(0xc20803acc0, 0xc2080527e0, 0x0, 0x0)
/Users/pontus/Applications/exchange/src/ +0x54·026()
/Users/pontus/Applications/exchange/src/ +0xcb
created by*memdPipeline).ioLoop
/Users/pontus/Applications/exchange/src/ +0x10e
exit status 2

Hi again!

Sorry seems to be my misstake (or at least easily solvable) i simply removed the port from the connection string and then it found the topology so it seems because now it works!