{"record":{"id":"65e450973d1f250a","repo":"nautechsystems/nautilus_trader","slug":"timed-out-requesting-open-orders-for-perm-id-looku","errorCode":null,"errorMessage":"Timed out requesting open orders for perm_id lookup","messagePattern":"Timed out requesting open orders for perm_id lookup","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core.rs","lineNumber":2223,"sourceCode":"    }\n\n    async fn resolve_ib_order_id(\n        client: &Arc<Client>,\n        order_selector: IbOrderSelector,\n        account_id: AccountId,\n        request_timeout_secs: u64,\n    ) -> anyhow::Result<i32> {\n        let target_perm_id = match order_selector {\n            IbOrderSelector::OrderId(order_id) => return Ok(order_id),\n            IbOrderSelector::PermId(perm_id) => perm_id,\n        };\n\n        let timeout_dur = Duration::from_secs(request_timeout_secs);\n        let raw_account_id = raw_ib_account_code(&account_id);\n        let subscription = match tokio::time::timeout(timeout_dur, client.all_open_orders()).await {\n            Ok(Ok(subscription)) => subscription,\n            Ok(Err(e)) => anyhow::bail!(\"Failed to request open orders for perm_id lookup: {e}\"),\n            Err(_) => anyhow::bail!(\"Timed out requesting open orders for perm_id lookup\"),\n        };\n        let mut subscription = subscription.filter_data();\n\n        while let Some(order_result) = subscription.next().await {\n            let Orders::OrderData(data) = order_result? else {\n                continue;\n            };\n\n            if !Self::is_active_open_order(&data.order) {\n                continue;\n            }\n\n            if !data.order.account.is_empty() && data.order.account != raw_account_id {\n                continue;\n            }\n\n            if data.order.perm_id != target_perm_id {\n                continue;","sourceCodeStart":2205,"sourceCodeEnd":2241,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core.rs#L2205-L2241","documentation":"The perm_id lookup wraps client.all_open_orders() in tokio::time::timeout(request_timeout_secs). If the request does not complete in time, this error bails. It means TWS/Gateway accepted the connection but never responded to the open-orders request within the configured window.","triggerScenarios":"Calling the perm_id lookup while Gateway is unresponsive (busy, frozen, restarting), on very slow networks, or when request_timeout_secs is configured too small.","commonSituations":"IB Gateway hung or performing maintenance; large numbers of open orders slowing the response; low request_timeout_secs in adapter config; network latency/VPN issues.","solutions":["Increase request_timeout_secs in the adapter configuration","Check TWS/Gateway responsiveness and restart it if frozen","Retry the perm_id lookup after connectivity is restored","Investigate network latency between the client and Gateway"],"exampleFix":"// before\nlet request_timeout_secs = 5;\n// after\nlet request_timeout_secs = 30;","handlingStrategy":"retry","validationCode":"// pre-flight ping with a small timeout before the lookup\ntokio::time::timeout(Duration::from_secs(2), client.check_health()).await\n    .map_err(|_| anyhow!(\"gateway unresponsive\"))?;","typeGuard":null,"tryCatchPattern":"match resolve_perm_id(...).await {\n    Err(e) if e.to_string().contains(\"Timed out requesting open orders\") => {\n        warn!(\"gateway slow; retrying with larger timeout\");\n        with_longer_timeout(|| retry_lookup()).await?\n    }\n    other => other?,\n}","preventionTips":["Set request_timeout_secs generously (e.g. 30s) for reconciliation paths","Monitor Gateway process health and restart if frozen","Avoid reconciliation during Gateway maintenance windows","Log timeouts with the configured timeout value for diagnosis"],"tags":["ibkr","orders","timeout","reconciliation"],"backgroundTag":"request-timeout","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"}