samuel / go-zookeeper

Native ZooKeeper client for Go. This project is no longer maintained. Please use https://github.com/go-zookeeper/zk instead.
BSD 3-Clause "New" or "Revised" License
1.64k stars 672 forks source link

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

Open elianka opened 5 years ago

elianka commented 5 years ago

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 commented 5 years ago

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