johnnadratowski / golang-neo4j-bolt-driver

Golang Bolt driver for Neo4j
MIT License
213 stars 72 forks source link

Could not connect to neo4j #45

Closed gaurav-gogia closed 6 years ago

gaurav-gogia commented 6 years ago

Hey, so I'm just getting started with this bolt driver for neo4j and looks like I cannot connect to the db. I'm using neo4j-community version 3.3.3

I've made sure that neo4j console is running and is accepting connections on port 7687

But looks like it's not really working. Below is the code & stack-trace. Am I doing something wrong?

Thanks ^.^

func main() {
 con := createConnection()
 defer con.Close()
}

func createConnection() bolt.Conn {
 driver := bolt.NewDriver()
 con, err := driver.OpenNeo(URI)
 handleError(err)
 return con
}

And here are the error(s) that I've got:

panic: An error occurred initializing connection
        An error occurred decoding ack failure message response
                Couldn't read expected bytes for message length. Read: 0 Expected: 2.
Internal Error(*errors.errorString):driver: bad connection

 Stack Trace:

goroutine 1 [running]:
runtime/debug.Stack(0x63354f, 0x46, 0xc42004fa58)
        /usr/lib64/golang/src/runtime/debug/stack.go:24 +0xa7
github.com/johnnadratowski/golang-neo4j-bolt-driver/errors.Wrap(0x71b9a0, 0xc420010070, 0x63354f, 0x46, 0xc42004fa58, 0x1, 0x1, 0xc420010070)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/errors/errors.go:38 +0x1a0
github.com/johnnadratowski/golang-neo4j-bolt-driver/encoding.Decoder.read(0x71b9e0, 0xc420086000, 0xc420098460, 0x412018, 0x70, 0x609e80)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/encoding/decoder.go:45 +0x471
github.com/johnnadratowski/golang-neo4j-bolt-driver/encoding.Decoder.Decode(0x71b9e0, 0xc420086000, 0xc420098460, 0xffff, 0x5f7da0, 0x7571d8, 0x0)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/encoding/decoder.go:93 +0x43
github.com/johnnadratowski/golang-neo4j-bolt-driver.(*boltConn).ackFailure(0xc420086000, 0xc420094060, 0xc42004fc18, 0x1)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/conn.go:402 +0x1bb
github.com/johnnadratowski/golang-neo4j-bolt-driver.(*boltConn).consume(0xc420086000, 0xc420086000, 0xc420098000, 0xc42009ffff, 0x606dc0)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/conn.go:555 +0x177
github.com/johnnadratowski/golang-neo4j-bolt-driver.(*boltConn).sendInit(0xc420086000, 0x0, 0x0, 0x0, 0x0)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/conn.go:611 +0x35f
github.com/johnnadratowski/golang-neo4j-bolt-driver.(*boltConn).initialize(0xc420086000, 0xc420086000, 0x4)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/conn.go:291 +0x168
github.com/johnnadratowski/golang-neo4j-bolt-driver.newBoltConn(0x629b22, 0x15, 0xc42000e038, 0x5f6b20, 0x1, 0xc42000e038)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/conn.go:102 +0xfd
github.com/johnnadratowski/golang-neo4j-bolt-driver.(*boltDriver).OpenNeo(0xc42000e038, 0x629b22, 0x15, 0xa, 0x71ba60, 0xc42000e030, 0xc42004ff60)
        /home/desmondanimus/go/src/github.com/johnnadratowski/golang-neo4j-bolt-driver/driver.go:62 +0x3f
main.createConnection(0xc42001c118, 0x0)
        /home/desmondanimus/learning/go/neo.go:43 +0x54
main.main()
        /home/desmondanimus/learning/go/neo.go:21 +0x26

goroutine 1 [running]:
main.handleError(0x71baa0, 0xc4200b6080)
        /home/desmondanimus/learning/go/neo.go:152 +0x4a
main.createConnection(0xc42001c118, 0x0)
        /home/desmondanimus/learning/go/neo.go:44 +0x80
main.main()
        /home/desmondanimus/learning/go/neo.go:21 +0x26
gaurav-gogia commented 6 years ago

Well, looks like I was using wrong URI. So here it is in case someone gets the same problem:

Use something like this while connecting with your db: bolt://username:password@localhost:7687