Help connect to couchbase


#1

i have this

package main

import (

"fmt"
//"github.com/golang/glog"
//"strconv"
"time"
"gopkg.in/couchbaselabs/gocb.v0"
//"github.com/couchbase/go-couchbase"

)

func main() {

callCouchbase("10.0.30.98:8092", "power", "d3v3nv" )

}

func callCouchbase(connection string, bucket string, password string) {
connection_string := “couchbase://” + connection
var err error
fmt.Println(“Opening connection to couchbase at: %s\n”, connection_string)

cluster, err = gocb.Connect(connection_string)
if(err != nil) {
	fmt.Println("Unable to make connection to Couchbase server...")
}
fmt.Println("Opening couchbase bucket: %s with password: %s", bucket, password)
Couchbase, err = cluster.OpenBucket(bucket, password)
if(err != nil) {
	panic(err)
} else {
	fmt.Println(err, "Connected...")
}

}

when i run it i get
Opening connection to couchbase at: %s
couchbase://10.0.30.98:8092
Opening couchbase bucket: %s with password: %s power d3v3nv
panic: Failed to connect to all specified hosts.

goroutine 1 [running]:
main.callCouchbase(0x7736d0, 0xf, 0x7846f0, 0xe, 0x769170, 0x6)
/root/go/src/test/test.go:47 +0x54c
main.main()
/root/go/src/test/test.go:27 +0x60

I am pulling my hair out . Thanks for the help.


#2

Hey mshivakumar,

You are using the couchbase scheme along with a hard-coded port of 8092, however, 8092 is actually not a bootstrap port. Please try to use

callCouchbase("10.0.30.98:11210", "power", "d3v3nv" )

or simply:

callCouchbase("10.0.30.98", "power", "d3v3nv" )

Cheers, Brett


#3

Hi,
it is a Empty bucket (power ) i created . I tried it with no port and with port 11210 and when i try to edit the bucket configuration i see Standard port (TCP port 11211. Needs SASL auth.) so i tried it with 11211 as well i still get the error Failed to connect to all specified hosts.
Just for fun i changed the passowrd to “somethingwrong”, as always it sits there and thinks for 2 mins and says Failed to connect to all specified hosts.does that say some thing.
Thanks for the help .


#4

i trashed all the things i am doing on i just tried

package main

import (
github.com/couchbaselabs/gocb
)

func main() {
myCluster, _ := gocb.Connect(“couchbase://10.0.30.98”) // ip address where couch is installed
myBucket, _ := myCluster.OpenBucket(“beer-sample”, “d3v3nv”) // that is my pass

var beer map[string]interface{}
cas, _ := myBucket.Get(“aass_brewery-juleol”, &beer)

beer[“comment”] = “Random beer from Norway”

myBucket.Replace(“aass_brewery-juleol”, &beer, cas, 0)
}

when i run it i get

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

goroutine 1 [running]:
github.com/couchbaselabs/gocb.func·004(0xc20803aae0, 0x0, 0x0, 0x0, 0x0)
/root/go/src/github.com/couchbaselabs/gocb/bucket_crud.go:99 +0x85
github.com/couchbaselabs/gocb.(*Bucket).hlpGetExec(0x0, 0x649f80, 0xc20802c018, 0xc20806bec8, 0x0, 0x0, 0x0)
/root/go/src/github.com/couchbaselabs/gocb/bucket_crud.go:24 +0x213
github.com/couchbaselabs/gocb.(*Bucket).Get(0x0, 0x76f9f0, 0x13, 0x649f80, 0xc20802c018, 0x0, 0x0, 0x0)
/root/go/src/github.com/couchbaselabs/gocb/bucket_crud.go:101 +0x7d
main.main()
/root/go/src/test2/test.go:12 +0xd6

the error is inline cas, _ := myBucket.Get(“aass_brewery-juleol”, &beer)

Thanks for your advice and help.