{"record":{"id":"1d66ecb082370db9","repo":"t8y2/dbx","slug":"read-zookeeper-connect-response-w","errorCode":null,"errorMessage":"read ZooKeeper connect response: %w","messagePattern":"read ZooKeeper connect response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/zookeeper_protocol.go","lineNumber":160,"sourceCode":"\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)\n\t}\n\tif sessionID == 0 {\n\t\treturn nil, zk.ErrSessionExpired\n\t}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/zookeeper_protocol.go#L142-L178","documentation":"After writing the connect request, newProtocolZooKeeperClient reads the server's connect response frame via readFrame. If reading fails (EOF, connection closed, timeout, short frame), the error is wrapped as 'read ZooKeeper connect response'. The server was reached but never delivered a complete handshake reply.","triggerScenarios":"Calling newProtocolZooKeeperClient (via connectKerberosZooKeeper or the protocol tests) where readFrame errors: peer closed the connection after receiving the connect request, read deadline expired before a response, or the server returned a truncated/invalid frame.","commonSituations":"ZooKeeper server rejecting the client and closing mid-handshake (maxClientCnxns exceeded, wrong port hitting a non-ZK service); overly aggressive timeout killing a slow session establishment; proxy intercepting the protocol stream.","solutions":["Check server-side limits (maxClientCnxns, connection queue) in zoo.cfg — servers drop clients at the limit","Verify the port is really ZooKeeper and not another service that closes on unknown bytes","Increase the connect timeout so slow ensembles can respond within the read deadline","Inspect server logs for connection drops at the same timestamp and retry with failover"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := tcpReachable(address, 5*time.Second); err != nil { return fmt.Errorf(\"zk %s unreachable: %w\", address, err) }","typeGuard":null,"tryCatchPattern":"client, err := newProtocolZooKeeperClient(conn, timeout)\nif err != nil {\n    if strings.Contains(err.Error(), \"read ZooKeeper connect response\") {\n        // server reached but no reply: retry next member / increase deadline\n        return dialNextMember(ensemble)\n    }\n    return err\n}","preventionTips":["Verify maxClientCnxns and connection limits are not exceeded server-side","Use deadlines comfortably above worst-case session establishment time","Confirm the port speaks ZooKeeper protocol (no HTTP/admin port mixups)","Fail over across ensemble members on read errors"],"tags":["zookeeper","network","protocol","timeout"],"backgroundTag":"connection-reset","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}