{"record":{"id":"581705dea8f3dbfa","repo":"nautechsystems/nautilus_trader","slug":"failed-to-subscribe-to-user-orders-e","errorCode":null,"errorMessage":"failed to subscribe to user orders: {e}","messagePattern":"failed to subscribe to user orders: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/execution.rs","lineNumber":563,"sourceCode":"\n        let session_result = async {\n            self.ws_client\n                .connect()\n                .await\n                .context(\"failed to connect WebSocket client for execution\")?;\n\n            self.ws_client\n                .authenticate_session(DERIBIT_EXECUTION_SESSION_NAME)\n                .await\n                .map_err(|e| anyhow::anyhow!(\"failed to authenticate WebSocket session: {e}\"))?;\n\n            log::debug!(\"WebSocket client authenticated for execution\");\n\n            // Subscribe to user order and trade updates for all instruments\n            self.ws_client\n                .subscribe_user_orders()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"failed to subscribe to user orders: {e}\"))?;\n            self.ws_client\n                .subscribe_user_trades()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"failed to subscribe to user trades: {e}\"))?;\n            self.ws_client\n                .subscribe_user_portfolio()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"failed to subscribe to user portfolio: {e}\"))?;\n\n            if let Err(e) = self.ws_client.wait_for_subscriptions_confirmed(30.0).await {\n                // Roll back subscription state so a retry re-sends subscribe requests\n                let _ = self.ws_client.unsubscribe_user_orders().await;\n                let _ = self.ws_client.unsubscribe_user_trades().await;\n                let _ = self.ws_client.unsubscribe_user_portfolio().await;\n                anyhow::bail!(\"subscription confirmation failed: {e}\");\n            }\n\n            log::debug!(\"Subscribed to user order, trade, and portfolio updates\");","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/execution.rs#L545-L581","documentation":"Raised in `DeribitExecutionClient::connect` after WebSocket authentication succeeds, when the `private` channel subscription for user order updates fails. The client maps the underlying ws-client error into an anyhow error and aborts connect, since order fills/updates would otherwise be silently missed. This is a fatal setup error for an execution client: without the user-orders channel the adapter cannot track order state.","triggerScenarios":"Calling `connect()` on a DeribitExecutionClient where `ws_client.subscribe_user_orders().await` returns Err — e.g. the underlying JSON-RPC `private/subscribe` to `user.orders.*` channels is rejected, the session dropped mid-request, the network failed, or the ws client was already closed.","commonSituations":"Expired or partially-scoped Deribit API credentials where private subscriptions are rejected; network/proxy drops between auth and subscribe; attempting to connect while the WebSocket is disconnected or reconnecting; testnet/mainnet URL misconfiguration; rate-limit rejection of the subscribe RPC.","solutions":["Check connect logs for the inner `{e}` detail from the ws client to see the actual JSON-RPC failure reason.","Verify API key/secret are valid, active, and scoped for the chosen environment (testnet vs production) before connecting.","Ensure network connectivity/proxy/firewall allows a persistent wss connection to the Deribit endpoint.","Reconnect the underlying WebSocket (or recreate the client) and retry connect; connect is re-runnable after the rollback path resets subscription state.","Check Deribit rate limits / subscription quotas if many clients subscribe concurrently."],"exampleFix":"// before\nlet client = DeribitExecutionClient::new(...);\nclient.connect().await?; // may fail: failed to subscribe to user orders\n\n// after\nfor attempt in 1..=3 {\n    match client.connect().await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"failed to subscribe\") && attempt < 3 => {\n            tokio::time::sleep(Duration::from_secs(2u64.pow(attempt))).await;\n        }\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":"// before connect\nassert!(api_key.is_some() && api_secret.is_some(), \"Deribit credentials required\");\nassert!(ws_endpoint_is_reachable(&url).await, \"Deribit ws endpoint unreachable\");","typeGuard":null,"tryCatchPattern":"// Rust\nmatch client.connect().await {\n    Err(e) if format!(\"{e:#}\").contains(\"failed to subscribe to user orders\") => {\n        // log inner cause, backoff, retry connect\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Validate Deribit API credentials against the correct environment before connect.","Keep the underlying WebSocket connected and authenticated before subscribing.","Wrap connect in bounded retry with exponential backoff.","Monitor network stability for long-lived wss sessions."],"tags":["websocket","subscription","deribit","execution-client","network"],"backgroundTag":"api-request-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}