{"record":{"id":"c56ebfe22d234654","repo":"vectordotdev/vector","slug":"encountered-a-connection-time-error-during-runtime","errorCode":null,"errorMessage":"Encountered a connection-time error during runtime: {:?}","messagePattern":"Encountered a connection-time error during runtime: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/websocket/source.rs","lineNumber":152,"sourceCode":"                                std::io::ErrorKind::TimedOut,\n                                \"Pong timeout\"\n                            ))\n                        });\n                        emit!(WebSocketConnectionShutdown);\n                        return Err(error);\n                    }\n                    WebSocketSourceError::Tungstenite { source: ws_err } => {\n                        if is_closed(&ws_err) {\n                            emit!(WebSocketConnectionShutdown);\n                        }\n                        error!(message = \"WebSocket connection error.\", error = %ws_err);\n                    }\n                    // These errors should only happen during `connect` or `reconnect`,\n                    // not in the main loop's result.\n                    WebSocketSourceError::ConnectTimeout\n                    | WebSocketSourceError::InitialMessageTimeout\n                    | WebSocketSourceError::ConnectionClosedPrematurely => {\n                        unreachable!(\n                            \"Encountered a connection-time error during runtime: {:?}\",\n                            error\n                        );\n                    }\n                }\n                if self\n                    .reconnect(&mut out, &mut ws_sink, &mut ws_source)\n                    .await\n                    .is_err()\n                {\n                    break;\n                }\n            }\n        }\n        Ok(())\n    }\n\n    async fn handle_message(","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sources/websocket/source.rs#L134-L170","documentation":"The websocket source classifies errors into connect-time (ConnectTimeout, InitialMessageTimeout, ConnectionClosedPrematurely) and runtime variants; only runtime errors should surface from the main receive loop. The loop matches connect-time variants with unreachable! because by construction they can only occur inside connect()/reconnect(), never from a live connection's next().","triggerScenarios":"An error classified as connect-time being returned by the live-connection stream - tokio-tungstenite surfacing a handshake/timeout error mid-session after a version change, or the source's error wrapper misclassifying variants when reconnect bookkeeping changes.","commonSituations":"Upgrades of tokio-tungstenite/tungstenite altering when errors are produced; non-conforming WS servers or intermediaries (proxies, load balancers) producing handshake-shaped errors mid-stream; custom error-classification patches.","solutions":["Upgrade Vector so the bundled tungstenite version matches the tested classification","Point the source at a compliant endpoint (test the same URL with websocat/wscat) and rule out intermediaries mangling the session","Reproduce with debug logging around reconnects and report the error sequence","If a proxy is involved, adjust websocket keepalive/proxy buffering settings for that route"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Source task panic = source failure; reconnect at the pipeline level with bounded retries:\nloop {\n    if let Err(je) = tokio::spawn(websocket::run(cfg.clone(), shutdown.clone())).await {\n        if je.is_panic() {\n            tokio::time::sleep(backoff.next()).await; // then continue; break after N tries\n            continue;\n        }\n    }\n    break;\n}","preventionTips":["Validate the WS endpoint with websocat/wscat before pointing Vector at it","Re-test websocket sources after server/proxy infrastructure changes","Run with RUST_BACKTRACE=1 to capture classification panics for reports"],"tags":["rust","vector","websocket","source","error-classification","panic","invariant"],"backgroundTag":"websocket-state-machine-violation","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}