{"record":{"id":"8f3b46005faae8bf","repo":"nautechsystems/nautilus_trader","slug":"output-channel-not-initialized","errorCode":null,"errorMessage":"Output channel not initialized","messagePattern":"Output channel not initialized","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/websocket/public_json/client.rs","lineNumber":500,"sourceCode":"        let cache = instruments\n            .iter()\n            .map(|instrument| (instrument.raw_symbol().inner(), instrument.clone()))\n            .collect();\n        self.instruments_cache.store(cache);\n    }\n\n    /// Returns a shared reference to the instruments cache.\n    #[must_use]\n    pub fn instruments_cache(&self) -> Arc<AtomicMap<Ustr, InstrumentAny>> {\n        self.instruments_cache.clone()\n    }\n\n    async fn create_connection(&self, slot_index: usize) -> anyhow::Result<ConnectionSlot> {\n        let out_tx = self\n            .out_tx\n            .lock()\n            .clone()\n            .ok_or_else(|| anyhow::anyhow!(\"Output channel not initialized\"))?;\n\n        let (raw_handler, raw_rx) = channel_message_handler();\n        let ping_handler: PingHandler = Arc::new(move |_| {});\n\n        let config = WebSocketConfig {\n            url: self.url.clone(),\n            headers: vec![],\n            heartbeat_interval_secs: self.heartbeat,\n            heartbeat_payload: None,\n            connect_timeout_ms: Some(5_000),\n            reconnect_delay_initial_ms: Some(500),\n            reconnect_delay_max_ms: Some(5_000),\n            reconnect_backoff_factor: Some(2.0),\n            reconnect_jitter_ms: Some(250),\n            reconnect_max_attempts: None,\n            heartbeat_timeout_secs: None,\n            idle_timeout_ms: None,\n            backend: self.transport_backend,","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/websocket/public_json/client.rs#L482-L518","documentation":"create_connection() clones the pool's shared output sender (out_tx) to give the new connection a sink for parsed messages. This error means out_tx was None — the pool was constructed but its output channel was never initialized (or already taken/reset), so no connection can be created.","triggerScenarios":"Calling connect() or subscribe() (which call create_connection) on a client whose out_tx Option is None — typically a client created but never hooked to an output channel, or one whose output channel was cleared during shutdown/reset.","commonSituations":"Constructing the WS client manually without calling the initialization that installs out_tx; using a client after close/reset cleared the channel; wrong initialization order in custom wiring of the data engine.","solutions":["Initialize the client's output channel before connecting (use the constructor/factory that sets out_tx, e.g. the one taking the Messager/output sender).","Verify initialization order: set up the output channel and message bus before any connect()/subscribe() call.","Do not reuse a client after its output channel has been dropped/reset; build a fresh client.","Check that the shutdown/reset path you run does not clear out_tx while connects are still expected."],"exampleFix":"// before\nlet client = BinanceSpotPublicJsonWsClient::new(config); // out_tx never set\nclient.connect().await?; // Err: Output channel not initialized\n\n// after\nlet client = BinanceSpotPublicJsonWsClient::new_with_output(config, out_tx); // set channel first\nclient.connect().await?;","handlingStrategy":"validation","validationCode":"// ensure output channel is installed before any connect/subscribe\nassert!(client.has_output_channel(), \"out_tx must be initialized before connect\");","typeGuard":null,"tryCatchPattern":"match client.connect().await {\n    Err(e) if e.to_string().contains(\"Output channel not initialized\") => {\n        anyhow::bail!(\"client misconfigured: initialize output channel before connecting\");\n    }\n    r => r,\n}","preventionTips":["Always construct the client via the factory that sets the output channel.","Initialize the message-bus wiring before any connect()/subscribe() call.","Never reuse a client after shutdown/reset cleared its channel; build a new one.","Add an early startup assertion that the output sink is present."],"tags":["initialization","channel","websocket","state"],"backgroundTag":"missing-required-config-field","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}