t8y2/dbx · error
Not connected
Error message
Not connected
What it means
server.requireClient returns the currently active ZooKeeper session, and 'Not connected' when service.activeClient is nil. Operations (get, put, delete, listPrefix, connectionInfo) call it first, so any operation issued before openClient succeeds or after the client was closed yields this error.
Source
Thrown at agents/drivers/zookeeper/connection.go:537
func millisecondsOrDefault(value int, fallback time.Duration) time.Duration {
if value <= 0 {
return fallback
}
return time.Duration(value) * time.Millisecond
}
func configuredStatLookupConcurrency(value string) int {
parsed, err := strconv.Atoi(strings.TrimSpace(value))
if err != nil {
return defaultStatLookupWorkers
}
return maxInt(minimumStatLookupWorkers, minInt(maximumStatLookupWorkers, parsed))
}
func (service *server) requireClient() (znodeClient, error) {
if service.activeClient == nil {
return nil, errors.New("Not connected")
}
return service.activeClient, nil
}
func (service *server) closeClient() {
if service.activeClient != nil {
service.activeClient.Close()
service.activeClient = nil
}
service.activeConfig = connectionConfig{}
}
func (session *clientSession) Close() {
if session != nil && session.connection != nil {
session.connection.Close()
}
}
View on GitHub (pinned to c0390bff16)
Solutions
- Call connect (openClient) and confirm it returns successfully before issuing any get/put/delete/list operations.
- Reconnect after a failure: catch connection errors and re-run connect to repopulate activeClient before retrying the operation.
- Check lifecycle ordering in your app so the driver's connect completes (or blocks) before workers start issuing operations.
- Inspect logs for the earlier error that closed the client (timeout, auth failure) — this error is a symptom of that.
Example fix
// before
val, err := driver.Get(ctx, "/foo") // activeClient nil -> Not connected
// after
if err := driver.Connect(ctx, cfg); err != nil { return err }
val, err := driver.Get(ctx, "/foo") Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the driver is connected before operations
if driver.ActiveClient() == nil {
if err := driver.Connect(ctx, cfg); err != nil {
return fmt.Errorf("cannot connect to zookeeper before operation: %w", err)
}
} Type guard
func connected(d *Server) bool { return d.ActiveClient() != nil }
// usage: if !connected(driver) { reconnect first } Try / catch
val, err := driver.Get(ctx, key)
if err != nil && strings.Contains(err.Error(), "Not connected") {
if cerr := driver.Connect(ctx, cfg); cerr != nil { return cerr }
val, err = driver.Get(ctx, key) // retry once after reconnect
} Prevention
- Sequence app startup: connect before any KV operations
- Implement an auto-reconnect wrapper around all operations
- Log and alert on the underlying error that closed the client
- Add a readiness probe that requires an active ZooKeeper session
When it happens
Trigger: Calling dispatch operations (get/put/delete/listPrefix/connectionInfo) before a successful connect, after closeClient ran (connection closed or failed and was torn down), or after a connection attempt returned an error leaving activeClient nil. Raised in agents/drivers/zookeeper/connection.go:537.
Common situations: Using the driver without calling connect/openClient first; the ZooKeeper connection dropped and the driver closed the active client, then a request arrived; app startup ordering issuing KV operations before the connector finishes init; a failed reconnect leaving the server struct without a client.
Related errors
- Not connected
- ZooKeeper event stream closed before a session was establish
- ZooKeeper event stream closed before a session was establish
- not connected
- not connected
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/2129773b68610804.
Report an issue: GitHub.