{"record":{"id":"1dac09bc3b92359a","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-rtds-action-request-e","errorCode":null,"errorMessage":"failed to send RTDS {action} request: {e}","messagePattern":"failed to send RTDS (.+?) request: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/rtds.rs","lineNumber":1099,"sourceCode":"\n    async fn send_wire_request(\n        &self,\n        ws: &Arc<WebSocketClient>,\n        action: &'static str,\n        subscriptions: Vec<RtdsWireSubscription>,\n    ) -> anyhow::Result<()> {\n        if subscriptions.is_empty() {\n            return Ok(());\n        }\n\n        let request = RtdsWireRequest {\n            action,\n            subscriptions,\n        };\n        let payload = serde_json::to_string(&request)?;\n        ws.send_text(payload, None)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"failed to send RTDS {action} request: {e}\"))\n    }\n\n    async fn run_message_loop(\n        &self,\n        ws: Arc<WebSocketClient>,\n        mut raw_rx: tokio::sync::mpsc::UnboundedReceiver<Message>,\n    ) {\n        loop {\n            match raw_rx.recv().await {\n                Some(Message::Text(text)) => {\n                    if text.as_str() == RECONNECTED {\n                        log::info!(\"Polymarket RTDS reconnected\");\n                        self.request_reconcile(ReconcileReason::TransportReset);\n                        continue;\n                    }\n\n                    if text.as_str() == \"PONG\" {\n                        continue;","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/rtds.rs#L1081-L1117","documentation":"The RTDS client sends subscription/request payloads over the WebSocket via ws.send_text; when the send fails, it wraps the underlying WebSocketClient error as 'failed to send RTDS {action} request: {e}'. It means the control-plane message for the given action (e.g. subscribe/auth) never reached Polymarket's RTDS gateway.","triggerScenarios":"Calling the RTDS request-sending path while the WebSocket connection is closed, dropped, or the outbound channel is full/closed — the serde_json::to_string of the request succeeded but transport failed.","commonSituations":"Network outage mid-session, server closing the socket after auth failure, attempting to (re)subscribe on a dead connection, or sending before the connection handshake finished.","solutions":["Retry after the connection is re-established; RTDS reconnect logic typically resubscribes automatically","Check the inner error (after ': {e}') to distinguish closed socket vs write failure","Verify the RTDS endpoint is reachable and the socket is connected before sending requests","Inspect auth state — servers often close sockets after auth expiry, making the next send fail"],"exampleFix":"// before\nws.send_text(payload, None).await?;\n// after\nif !ws.is_connected() { reconnect().await?; }\nws.send_text(payload, None).await\n    .map_err(|e| { warn!(\"RTDS {action} send failed: {e:#}\"); e })?;","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust\nmatch send_rtds_request(action, subscriptions).await {\n    Err(e) if e.to_string().contains(\"failed to send RTDS\") => {\n        reconnect().await?;\n        send_rtds_request(action, subscriptions).await?;\n    }\n    other => other?,\n}","preventionTips":["Check connection state before sending RTDS control messages","Rely on the adapter's resubscribe-on-reconnect flow instead of manual sends on stale sockets","Watch auth expiry — servers close sockets after it, making subsequent sends fail"],"tags":["websocket","network","polymarket","rtds","realtime"],"backgroundTag":"broken-pipe","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"}