{"record":{"id":"4f1e46b0a9e8ac5d","repo":"tracel-ai/burn","slug":"failed-to-receive-message-from-websocket-err","errorCode":null,"errorMessage":"Failed to receive message from websocket: {err:?}","messagePattern":"Failed to receive message from websocket: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-communication/src/external_comm.rs","lineNumber":255,"sourceCode":"            match channel.recv().await {\n                Ok(message) => {\n                    if let Some(msg) = message {\n                        let bytes = msg.data;\n                        let msg: ExternalCommMessage = rmp_serde::from_slice(&bytes)\n                            .expect(\"Can deserialize messages from the websocket.\");\n                        let ExternalCommMessage::TensorRequest(transfer_id) = msg else {\n                            panic!(\"Received a message that wasn't a tensor request! {msg:?}\");\n                        };\n\n                        let bytes = self.get_exposed_tensor_bytes(transfer_id).await.unwrap();\n\n                        channel.send(Message::new(bytes)).await.unwrap();\n                    } else {\n                        log::info!(\"Closed connection\");\n                        return;\n                    }\n                }\n                Err(err) => panic!(\"Failed to receive message from websocket: {err:?}\"),\n            };\n        }\n        log::info!(\"[Data Service] Closing connection for download.\");\n    }\n}\n","sourceCodeStart":237,"sourceCodeEnd":261,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-communication/src/external_comm.rs#L237-L261","documentation":"While serving tensor downloads on the 'data' channel, the server awaits WebSocket messages; a receive error (connection reset, abnormal close, timeout, protocol violation) panics with the underlying error. Unlike a clean close (which just returns), this is an unexpected transport failure mid-session.","triggerScenarios":"Client disconnects abruptly (process killed, network drop) during a tensor download; proxy/load-balancer idle timeout closing the socket; WebSocket frame/protocol error raised by the underlying ws implementation.","commonSituations":"Long downloads across flaky links or mobile networks; Kubernetes ingress with short idle timeouts; clients cancelled mid-transfer (e.g. tokio task aborted) leaving a reset connection.","solutions":["Retry the tensor download; the server connection is gone and must be re-established.","Increase idle/read timeouts on any proxy between client and server.","Check network stability (MTU, firewall, keep-alive/ping settings on the WebSocket).","Inspect the {err:?} payload to distinguish reset vs timeout vs protocol error and address accordingly."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Set keep-alive/ping and read timeouts on the socket before serving\nlet ws = configure_keepalive(ws, Duration::from_secs(30));","typeGuard":null,"tryCatchPattern":"// Client retries the whole download on transport failure\nmatch download(addr).await {\n    Ok(d) => Ok(d),\n    Err(e) => { tokio::time::sleep(Duration::from_secs(1)).await; download(addr).await }\n}","preventionTips":["Enable WebSocket ping/keep-alive to survive idle proxies","Raise proxy/ingress idle timeouts for long transfers","Expect abrupt disconnects; make the client idempotently retry downloads","Log {err:?} to distinguish reset vs timeout vs protocol error"],"tags":["network","websocket","burn","remote"],"backgroundTag":"websocket-connection-reset","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}