{"record":{"id":"bd9f95f46a2c15ce","repo":"nautechsystems/nautilus_trader","slug":"failed-to-connect-binance-spot-public-json-websock","errorCode":null,"errorMessage":"failed to connect Binance Spot public JSON WebSocket: {e}","messagePattern":"failed to connect Binance Spot public JSON WebSocket: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/data.rs","lineNumber":1576,"sourceCode":"                                    &book_epoch,\n                                    &http,\n                                    clock,\n                                );\n                            }\n                            () = cancel.cancelled() => {\n                                log::debug!(\"Spot SBE WebSocket stream task cancelled\");\n                                break;\n                            }\n                        }\n                    }\n                });\n                self.tasks.push(handle);\n            }\n            SpotWsClient::JsonPublic(ws_client) => {\n                log::info!(\"Connecting to Binance Spot public JSON WebSocket...\");\n                ws_client.connect().await.map_err(|e| {\n                    log::error!(\"Binance Spot public JSON WebSocket connection failed: {e:?}\");\n                    anyhow::anyhow!(\"failed to connect Binance Spot public JSON WebSocket: {e}\")\n                })?;\n                log::info!(\"Binance Spot public JSON WebSocket connected\");\n\n                let stream = ws_client.stream();\n                let sender = self.data_sender.clone();\n                let insts = self.instruments.clone();\n                let ws_insts = 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 book_epoch = self.book_epoch.clone();\n                let http = self.http_client.clone();\n                let clock = self.clock;\n                let cancel = self.cancellation_token.clone();\n\n                let handle = get_runtime().spawn(async move {\n                    pin_mut!(stream);\n","sourceCodeStart":1558,"sourceCodeEnd":1594,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/data.rs#L1558-L1594","documentation":"The Binance Spot public JSON market data WebSocket (used for trades, book, and other public streams) failed to connect; the underlying cause is preserved in {e} and logged in Debug form. Because this stream is public, failures are almost always network/DNS/firewall/proxy related rather than authentication.","triggerScenarios":"connect() on the Spot public JSON stream fails: DNS resolution failure, firewall or regional blocking of the Binance streaming endpoint, TLS interception breaking the upgrade, proxy misconfiguration, or invalid endpoint configuration.","commonSituations":"Running in a region where binance.com endpoints are restricted; containerized or corporate egress requiring a proxy that is not configured; transient network outage at startup.","solutions":["Read {e} to classify: timeouts/DNS point to network, HTTP status codes point to blocking or configuration","Test raw reachability of the Binance Spot WebSocket endpoint from the same host (e.g. a manual WebSocket handshake)","Configure proxy_url if egress requires a proxy","Retry on transient failures; the connect happens during client start, so restart or trigger reconnection after fixing the network"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Pre-flight network check to the Spot public stream before node start\nimport socket, urllib.parse\nhost = urllib.parse.urlparse(\"wss://stream.binance.com:9443\").hostname\nsocket.getaddrinfo(host, 9443)  # raises if DNS/egress is blocked","typeGuard":null,"tryCatchPattern":"Retry connect with exponential backoff and jitter; classify {e} first — DNS/timeout means infrastructure (fix egress/proxy and retry), HTTP-level blocks may require a proxy or a different network path rather than retrying.","preventionTips":["Verify egress to Binance streaming endpoints from the deployment network","Configure proxy_url where egress requires a proxy","Run connectivity smoke tests in deployment pipelines"],"tags":["binance","spot","websocket","connection","network"],"backgroundTag":"websocket-connection-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}