Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

why zk.Connect always return no error even if zk server is down? #198

Open
elianka opened this issue Nov 13, 2018 · 1 comment
Open

why zk.Connect always return no error even if zk server is down? #198

elianka opened this issue Nov 13, 2018 · 1 comment

Comments

@elianka
Copy link

elianka commented Nov 13, 2018

i found that zk.Connect return no error when zk server is error or down.
i don't know why? i think it should return error when service is unreachable or timeout.
`package main

import (
"fmt"
"time"

    "github.com/samuel/go-zookeeper/zk"

)

func main() {
c, _, err := zk.Connect([]string{"127.0.0.1"}, time.Second) //*10)
if err != nil {
panic(err)
}
fmt.Printf("reach here. no error for zk.Connect! But there is no zk service running \n")
children, stat, ch, err := c.ChildrenW("/")
if err != nil {
panic(err)
}
fmt.Printf("%+v %+v\n", children, stat)
e := <-ch
fmt.Printf("%+v\n", e)
}`

image

@TomerHeber
Copy link

Haven't tried, but my guess is that you should check the returned channel for connection status.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants