{"record":{"id":"3608eac2923a72ae","repo":"nautechsystems/nautilus_trader","slug":"subscription-error-e","errorCode":null,"errorMessage":"Subscription error: {e:?}","messagePattern":"Subscription error: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/data/core_streams.rs","lineNumber":1088,"sourceCode":"                                e\n                            );\n\n                            if !wait_for_data_farm_recovery_or_cancel(\n                                &data_farm_state,\n                                farm_generation,\n                                &cancellation_token,\n                            )\n                            .await\n                            {\n                                subscription.cancel().await;\n                                return Ok(());\n                            }\n                            farm_generation = data_farm_state.recovery_generation();\n                            break;\n                        }\n                        Some(Err(e)) => {\n                            tracing::error!(\"Subscription error for {}: {:?}\", instrument_id, e);\n                            anyhow::bail!(\"Subscription error: {e:?}\");\n                        }\n                        None => break,\n                    }\n                }\n            }\n        }\n    }\n\n    Ok(())\n}\n\n#[allow(clippy::too_many_arguments)]\npub(super) async fn handle_trade_subscription(\n    client: Arc<ibapi::Client>,\n    contract: ibapi::contracts::Contract,\n    instrument_id: InstrumentId,\n    price_precision: u8,\n    size_precision: u8,","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/data/core_streams.rs#L1070-L1106","documentation":"While setting up a tick-by-tick quote subscription, the adapter awaits an acknowledgment from the IB stream; if the subscription future yields an Err (e.g. farm not connected, rejected subscription), the error is logged and propagated with the Debug form of the source error.","triggerScenarios":"Calling subscribe_quotes when the data farm is down/recovering, the instrument is not subscribed on the gateway, or the internal subscription channel returned an error — observed as Some(Err(e)) on the ack channel.","commonSituations":"IB Gateway/TWS disconnects mid-subscription, market data farm drops during recovery, requesting tick-by-tick data for unsupported instruments, or market-data permissions missing.","solutions":["Verify the IB Gateway/TWS connection is live and the market data farm is connected before subscribing","Retry the subscription (recovery generation handling suggests transient farm issues)","Confirm market data subscriptions/permissions cover the instrument's exchange","Check the inner error (logged as 'Subscription error for {instrument_id}') for the root cause"],"exampleFix":"// before\nclient.subscribe_quotes(instrument_id).await?;\n// after\nmatch client.subscribe_quotes(instrument_id).await {\n    Ok(stream) => ..., // use stream\n    Err(e) => {\n        tracing::warn!(\"quote subscription failed for {instrument_id}: {e:?}; retrying after reconnect\");\n        client.reconnect().await?;\n        client.subscribe_quotes(instrument_id).await?;\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.subscribe_quotes(instrument_id).await {\n    Ok(handle) => handle,\n    Err(e) if e.to_string().contains(\"Subscription error\") => {\n        tracing::warn!(\"transient subscription failure for {instrument_id}; retrying after backoff\");\n        tokio::time::sleep(Duration::from_secs(2)).await;\n        client.subscribe_quotes(instrument_id).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Confirm gateway connectivity and market data farm status before subscribing","Verify market data permissions for the instrument's exchange","Use tick-by-tick subscriptions only for supported instrument types","Monitor the inner error logged as 'Subscription error for {instrument_id}' for root cause"],"tags":["rust","subscription","market-data","interactive-brokers"],"backgroundTag":"subscription-failed","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"}