{"record":{"id":"22a6c7f5da5029e5","repo":"t8y2/dbx","slug":"send-zookeeper-connect-request-w","errorCode":null,"errorMessage":"send ZooKeeper connect request: %w","messagePattern":"send ZooKeeper connect request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/zookeeper_protocol.go","lineNumber":156,"sourceCode":"\tclosed     bool\n}\n\nfunc newProtocolZooKeeperClient(connection net.Conn, timeout time.Duration) (*protocolZooKeeperClient, error) {\n\tif connection == nil {\n\t\treturn nil, errors.New(\"ZooKeeper connection is nil\")\n\t}\n\tif timeout <= 0 {\n\t\ttimeout = defaultConnectTimeout\n\t}\n\tclient := &protocolZooKeeperClient{connection: connection, timeout: timeout}\n\trequest := &zooKeeperEncoder{}\n\trequest.int32(zooKeeperProtocolVersion)\n\trequest.int64(0)\n\trequest.int32(zooKeeperTimeoutMillis(timeout))\n\trequest.int64(0)\n\trequest.bytes(make([]byte, 16))\n\tif err := client.writeFrame(request.data()); err != nil {\n\t\treturn nil, fmt.Errorf(\"send ZooKeeper connect request: %w\", err)\n\t}\n\tresponse, err := client.readFrame()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read ZooKeeper connect response: %w\", err)\n\t}\n\tdecoder := newZooKeeperDecoder(response)\n\tif _, err := decoder.int32(); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode ZooKeeper protocol version: %w\", err)\n\t}\n\tif _, err := decoder.int32(); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode ZooKeeper session timeout: %w\", err)\n\t}\n\tsessionID, err := decoder.int64()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decode ZooKeeper session ID: %w\", err)\n\t}\n\tif _, err := decoder.bytes(); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode ZooKeeper session password: %w\", err)","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/zookeeper_protocol.go#L138-L174","documentation":"newProtocolZooKeeperClient builds the ZooKeeper connect request and writes it as a single frame with writeFrame; if the write fails (connection broken, closed, timed out) the error is wrapped as 'send ZooKeeper connect request'. This happens after the TCP/TLS connection succeeded but before any server response, indicating a transport-level problem during handshake.","triggerScenarios":"Calling connectKerberosZooKeeper (which invokes newProtocolZooKeeperClient) where the underlying net.Conn write of the connect frame fails: server closed the connection immediately after accept, network timeout mid-write, or TLS handshake accepted but peer reset the stream.","commonSituations":"ZooKeeper listener closed by a load balancer idle timeout; packet loss on the way to the ensemble; server crash between TCP accept and protocol read; Docker/K8s sidecar terminating the connection before the first frame.","solutions":["Check connectivity to the ZooKeeper host:port and any load balancer/idle-timeout in front of it","Ensure the ZooKeeper server is up and accepting connections (server log, 4lw 'ruok' command)","Increase the dial/session timeout if writes time out on slow links","Retry the connection — connectKerberosZooKeeper will fail over to the next ensemble member"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", address, 5*time.Second)\nif err != nil { return err }\nconn.Close() // reachability pre-check before the protocol handshake","typeGuard":null,"tryCatchPattern":"client, err := newProtocolZooKeeperClient(conn, timeout)\nif err != nil {\n    if errors.Is(err, syscall.ECONNRESET) || isTimeout(err) {\n        return retryWithBackoff(3, func() error { return dialAndConnect(address) })\n    }\n    return err\n}","preventionTips":["Tune load-balancer/idle timeouts to exceed session negotiation time","Set sane dial/write deadlines and retry transient IO errors with backoff","Monitor ZooKeeper server logs for dropped client connections","Fail over to the next ensemble member on send failures"],"tags":["zookeeper","network","protocol","io"],"backgroundTag":"connection-reset","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}