From 561bb2b4ec1d4ef744ebe2c99c02c681f0a5a962 Mon Sep 17 00:00:00 2001 From: CarlTsui Date: Thu, 23 Apr 2020 10:31:41 +0800 Subject: [PATCH] Update: In zookeeper 3.4.5, If zookeeper service discover an old client, it would close that connection. EOF should be considered as ErrSessionExpired. --- zk/conn.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zk/conn.go b/zk/conn.go index da9503a2..2337a673 100644 --- a/zk/conn.go +++ b/zk/conn.go @@ -712,6 +712,15 @@ func (c *Conn) authenticate() error { } _, err = io.ReadFull(c.conn, buf[:4]) if err != nil { + // Fix Bug for zookeeper old client + if err == io.EOF { + atomic.StoreInt64(&c.sessionID, int64(0)) + c.passwd = emptyPassword + c.lastZxid = 0 + c.setState(StateExpired) + return ErrSessionExpired + } + return err } if err := c.conn.SetReadDeadline(time.Time{}); err != nil {