{"record":{"id":"fefeab91476dae6e","repo":"nautechsystems/nautilus_trader","slug":"failed-to-connect-binance-futures-public-websocket","errorCode":null,"errorMessage":"failed to connect Binance Futures public WebSocket: {e}","messagePattern":"failed to connect Binance Futures public WebSocket: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":1580,"sourceCode":"            &self.ws_public_client,\n            &self.data_sender,\n            self.clock,\n            false,\n        )\n        .await?;\n\n        let session_result = async {\n            log::info!(\"Connecting to Binance Futures market WebSocket...\");\n            self.ws_client.connect().await.map_err(|e| {\n                log::error!(\"Binance Futures market WebSocket connection failed: {e:?}\");\n                anyhow::anyhow!(\"failed to connect Binance Futures market WebSocket: {e}\")\n            })?;\n            log::info!(\"Binance Futures market WebSocket connected\");\n\n            log::info!(\"Connecting to Binance Futures public WebSocket...\");\n            self.ws_public_client.connect().await.map_err(|e| {\n                log::error!(\"Binance Futures public WebSocket connection failed: {e:?}\");\n                anyhow::anyhow!(\"failed to connect Binance Futures public WebSocket: {e}\")\n            })?;\n            log::info!(\"Binance Futures public WebSocket connected\");\n\n            let stream = self.ws_client.stream();\n            let sender = self.data_sender.clone();\n            let insts = self.instruments.clone();\n            let ws_insts = self.ws_client.instruments_cache();\n            let buffers = self.book_buffers.clone();\n            let book_subs = self.book_subscriptions.clone();\n            let l1_book_subs = self.l1_book_subscriptions.clone();\n            let force_order_refs = self.force_order_refs.clone();\n            let ticker_refs = self.ticker_refs.clone();\n            let force_order_all_market_refs = self.force_order_all_market_refs.clone();\n            let force_order_all_market_stream_active =\n                self.force_order_all_market_stream_active.clone();\n            let book_epoch = self.book_epoch.clone();\n            let http = self.http_client.clone();\n            let clock = self.clock;","sourceCodeStart":1562,"sourceCodeEnd":1598,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L1562-L1598","documentation":"During BinanceFuturesDataClient::connect, the secondary public WebSocket client failed to connect after the market WebSocket already connected successfully. The whole connect() call fails, so both streams must be healthy for the client to initialize.","triggerScenarios":"Calling connect() on the Binance Futures data client when self.ws_public_client.connect() returns Err — the same network-level failures as the market socket, but on the public data endpoint.","commonSituations":"Firewall allowing one endpoint but blocking the other; geo-restriction on the public endpoint; transient public-endpoint outage right after the market socket succeeded.","solutions":["Verify connectivity to the Binance Futures public WebSocket endpoint specifically","Inspect the logged `Binance Futures public WebSocket connection failed: {e:?}` line for the root cause","Retry the connect with backoff; the market socket already connected so a full reconnect is needed on failure","Check that any proxy configuration applies to both WebSocket clients"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// both endpoints must be reachable\nfor host in [\"fstream.binance.com:443\", \"fstream.binance.com:443/ws\"] {\n    assert!(std::net::TcpStream::connect(host).is_ok(), \"endpoint unreachable: {host}\");\n}","typeGuard":null,"tryCatchPattern":"match client.connect().await {\n    Err(e) if e.to_string().contains(\"public WebSocket\") => {\n        // market socket succeeded but public failed: full reconnect needed\n        schedule_reconnect_with_backoff(e);\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {},\n}","preventionTips":["Firewall-test both WebSocket endpoints, not just one","Apply proxy env vars consistently to all WS clients","Treat connect() as all-or-nothing: always fully reconnect on partial failure"],"tags":["network","websocket","connection","binance-futures"],"backgroundTag":"connection-refused","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}