{"record":{"id":"a544c3a151cea9d6","repo":"nautechsystems/nautilus_trader","slug":"ws-submit-order-failed-e-a544c3","errorCode":null,"errorMessage":"WS submit order failed: {e}","messagePattern":"WS submit order failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":367,"sourceCode":"            dispatch_state.pending_requests.insert(\n                request_id.clone(),\n                PendingRequest {\n                    client_order_id,\n                    venue_order_id: None,\n                    operation: PendingOperation::Place,\n                },\n            );\n\n            self.spawn_task(\"submit_order_ws\", async move {\n                if let Err(e) = ws_client\n                    .place_order_with_id(request_id.clone(), params)\n                    .await\n                {\n                    dispatch_state.pending_requests.remove(&request_id);\n                    log::warn!(\n                        \"WS submit request failed for {client_order_id}, awaiting reconciliation: {e}\"\n                    );\n                    anyhow::bail!(\"WS submit order failed: {e}\");\n                }\n                Ok(())\n            });\n        } else {\n            let http_client = self.http_client.clone();\n            let dispatch_state = self.dispatch_state.clone();\n            log::debug!(\"WS trading not active, falling back to HTTP for submit_order\");\n\n            self.spawn_task(\"submit_order_http\", async move {\n                let result = http_client\n                    .submit_order(\n                        account_id,\n                        instrument_id,\n                        client_order_id,\n                        order_side,\n                        order_type,\n                        quantity,\n                        time_in_force,","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/execution.rs#L349-L385","documentation":"When use_ws_trading is active, orders are placed over the Binance Spot WebSocket API via place_order_with_id. If that call fails, the pending request id is removed from the dispatch state, a warning about awaiting reconciliation is logged, and the spawned task bails with this error. The order stays SUBMITTED locally and its true venue state must be resolved by reconciliation.","triggerScenarios":"The WS place-order request fails inside the spawned 'submit_order_ws' task: session/logon errors, WS rate limits, transient disconnects, or parameter rejections from the venue while the transport was still considered active.","commonSituations":"Flaky networks between the host and the Binance WS trading endpoint; expired sessions after idle periods; intermittent rate limiting during bursts of submissions; live trading where order state becomes uncertain.","solutions":["Rely on the adapter's reconciliation path to resolve the order's venue state before deciding to resubmit","Retry the submission after a backoff once the session is confirmed healthy and the order is confirmed absent on the venue","Set use_ws_trading=false so submission uses the HTTP REST path (the adapter automatically falls back when the WS transport is inactive)"],"exampleFix":"# before\nconfig = BinanceExecClientConfig(use_ws_trading=True)  # WS submit fails intermittently\n\n# after: route orders over REST, user data still streamed\nconfig = BinanceExecClientConfig(use_ws_trading=False)","handlingStrategy":"retry","validationCode":"# defensive: only submit when the WS trading transport is healthy or expect HTTP fallback\nif not self._engine.client_is_connected():\n    raise RuntimeError(\"venue not connected; refusing to submit\")","typeGuard":null,"tryCatchPattern":"// in a supervision loop around the execution client:\n// on 'WS submit order failed':\n//   1. run generate_order_status_reports (reconciliation) for the client_order_id\n//   2. if absent on venue -> resubmit after backoff\n//   3. if present        -> adopt the venue state and continue\n// order remains SUBMITTED locally until reconciled; do not blind-resubmit","preventionTips":["Watch WS session health metrics and quiesce submissions during reconnects","Run periodic reconciliation so uncertain order states resolve quickly","If the WS path is chronically unstable, set use_ws_trading=false for the REST path"],"tags":["binance","spot","websocket","order-submission","execution","reconciliation"],"backgroundTag":"order-submission-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}