{"record":{"id":"12eaff1361606cff","repo":"nautechsystems/nautilus_trader","slug":"e-12eaff","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/execution/spot.rs","lineNumber":588,"sourceCode":"            .ok_or_else(|| anyhow::anyhow!(\"missing WS auth token\"))?;\n\n        let params = build_cancel_order_params(cmd, token);\n        let identity = PendingRequest {\n            operation: PendingOperation::Cancel,\n            client_order_ids: vec![cmd.client_order_id],\n            venue_order_ids: vec![cmd.venue_order_id],\n            ts_sent_ns: 0,\n            new_quantity: None,\n            new_price: None,\n            new_trigger_price: None,\n        };\n        self.order_request_state\n            .cancel(params, identity, self.clock.get_time_ns().as_u64())?;\n        Ok(())\n    }\n\n    fn spawn_message_handler(&mut self) -> anyhow::Result<()> {\n        let stream = self.ws.stream().map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n        let emitter = self.emitter.clone();\n        let instruments = self.instruments.clone();\n        let order_qty_cache = self.order_qty_cache.clone();\n        let truncated_id_map = self.truncated_id_map.clone();\n        let dispatch_state = self.ws_dispatch_state.clone();\n        let order_request_state = self.order_request_state.clone();\n        let account_id = self.core.account_id;\n        let clock = self.clock;\n        let cancellation_token = self.cancellation_token.clone();\n\n        let future = async move {\n            tokio::pin!(stream);\n\n            loop {\n                tokio::select! {\n                    () = cancellation_token.cancelled() => {\n                        log::debug!(\"Spot execution message handler cancelled\");\n                        break;","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/execution/spot.rs#L570-L606","documentation":"Raised in `spawn_message_handler` on the Kraken spot execution client when acquiring the WebSocket message stream (`self.ws.stream()`) fails; the underlying error is re-wrapped with `anyhow::anyhow!(\"{e}\")`. This happens during `connect()` before the message-handling task starts, so it indicates the WebSocket client could not produce its receive stream at all.","triggerScenarios":"Calling `connect()` on the execution client when the underlying WS client is already shut down, its stream was already taken, or the WS library fails to initialize the stream (transport/socket setup failure).","commonSituations":"Double-connecting a client without disconnecting first; connecting after a previous connection was torn down and the WS actor exited; underlying websocket library/transport error during connection setup.","solutions":["Read the wrapped `{e}` message for the underlying websocket library's failure reason.","Do not call `connect()` twice on the same client instance; disconnect first or create a fresh client.","Check network/proxy/DNS reachability to Kraken's WS endpoint.","Recreate the execution client if its internal WS actor has terminated, then reconnect."],"exampleFix":"// before\nclient.connect()?;\nclient.connect()?; // second call: stream already taken -> error\n\n// after\nif !client.is_connected() {\n    client.connect()?;\n}","handlingStrategy":"try-catch","validationCode":"// Guard against double-connect.\nif client.is_connected() {\n    return Ok(()); // already streaming\n}","typeGuard":null,"tryCatchPattern":"match client.connect() {\n    Ok(()) => (),\n    Err(e) => {\n        log::error!(\"kraken exec connect failed: {e}; recreating client\");\n        client = KrakenExecClient::new(...)?;\n        client.connect()?;\n    }\n}","preventionTips":["Call connect() only once per client instance; use is_connected() guards.","Disconnect (or drop) a client before creating a new one for the same account.","Validate network reachability to Kraken WS endpoints before connect.","Recreate the client rather than re-connecting one whose WS actor has exited."],"tags":["websocket","kraken","connection","execution-client"],"backgroundTag":"connection-refused","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}