{"record":{"id":"66351c3b141c59dd","repo":"bcicen/ctop","slug":"attempting-to-reconnect","errorCode":null,"errorMessage":"attempting to reconnect...","messagePattern":"attempting to reconnect\\.\\.\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"connector/main.go","lineNumber":82,"sourceCode":"func (cs *ConnectorSuper) loop() {\n\tconst interval = 3\n\tfor {\n\t\tlog.Infof(\"initializing connector\")\n\n\t\tconn, err := cs.connFn()\n\t\tif err != nil {\n\t\t\tcs.setError(err)\n\t\t\tlog.Errorf(\"failed to initialize connector: %s (%T)\", err, err)\n\t\t\tlog.Errorf(\"retrying in %ds\", interval)\n\t\t\ttime.Sleep(interval * time.Second)\n\t\t} else {\n\t\t\tcs.conn = conn\n\t\t\tcs.setError(nil)\n\t\t\tlog.Infof(\"successfully initialized connector\")\n\n\t\t\t// wait until connection closed\n\t\t\tcs.conn.Wait()\n\t\t\tcs.setError(fmt.Errorf(\"attempting to reconnect...\"))\n\t\t\tlog.Infof(\"connector closed\")\n\t\t}\n\t}\n}\n\n// Enabled returns names for all enabled connectors on the current platform\nfunc Enabled() (a []string) {\n\tfor k, _ := range enabled {\n\t\ta = append(a, k)\n\t}\n\tsort.Strings(a)\n\treturn a\n}\n\n// ByName returns a ConnectorSuper for a given name, or error if the connector\n// does not exists on the current platform\nfunc ByName(s string) (*ConnectorSuper, error) {\n\tif cfn, ok := enabled[s]; ok {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/bcicen/ctop/blob/59f00dd6aaebf48f3bc501e174f75f815c2619f0/connector/main.go#L64-L100","documentation":"The ConnectorSuper loop waits on the active connection; when conn.Wait() returns (connection closed), it sets the internal error to 'attempting to reconnect...' until the next loop iteration re-establishes the connection. Get() during this window returns this transient error.","triggerScenarios":"The underlying connector's connection closes unexpectedly (container stopped, Docker daemon restart, network drop) and a Get() happens before the reconnect succeeds.","commonSituations":"Docker daemon restart while the app holds a connector; container stopped/removed underneath the client; transient network interruption in remote Docker setups.","solutions":["Retry Get() with backoff until reconnection completes (err becomes nil)","Add reconnection event handling/logging around the connector lifecycle","Verify the container/daemon is actually running if the error persists"],"exampleFix":"// before\nconn, err := cs.Get() // fails once after daemon restart\n// after\nvar conn connector.Connector\nfor i := 0; i < 10; i++ {\n  conn, err = cs.Get()\n  if err == nil { break }\n  time.Sleep(500 * time.Millisecond)\n}","handlingStrategy":"retry","validationCode":"// detect reconnect window\n_, err := cs.Get()\nreconnecting := err != nil && err.Error() == \"attempting to reconnect...\"","typeGuard":null,"tryCatchPattern":"conn, err := cs.Get()\nif err != nil && err.Error() == \"attempting to reconnect...\" {\n    // retry with backoff; connection is re-established by the loop\n    time.Sleep(500 * time.Millisecond)\n}","preventionTips":["Wrap Get() calls in a retry-with-backoff helper","Monitor container/daemon health to anticipate drops","Use exponential backoff with a max retry budget"],"tags":["reconnect","transient","connection"],"backgroundTag":"connection-lost-reconnecting","analyzedSha":"59f00dd6aaebf48f3bc501e174f75f815c2619f0","analyzedAt":"2026-09-02T23:34:03.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}