{"record":{"id":"393deff872803da7","repo":"nautechsystems/nautilus_trader","slug":"timeout-waiting-for-account-account-id-to-be-reg","errorCode":null,"errorMessage":"Timeout waiting for account {account_id} to be registered after {timeout_secs}s","messagePattern":"Timeout waiting for account (.+?) to be registered after (.+?)s","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/execution.rs","lineNumber":404,"sourceCode":"        if self.core.cache().account(&account_id).is_some() {\n            log::info!(\"Account {account_id} registered\");\n            return Ok(());\n        }\n\n        let start = Instant::now();\n        let timeout = Duration::from_secs_f64(timeout_secs);\n        let interval = Duration::from_millis(10);\n\n        loop {\n            tokio::time::sleep(interval).await;\n\n            if self.core.cache().account(&account_id).is_some() {\n                log::info!(\"Account {account_id} registered\");\n                return Ok(());\n            }\n\n            if start.elapsed() >= timeout {\n                anyhow::bail!(\n                    \"Timeout waiting for account {account_id} to be registered after {timeout_secs}s\"\n                );\n            }\n        }\n    }\n}\n\n#[async_trait(?Send)]\nimpl ExecutionClient for AxExecutionClient {\n    fn is_connected(&self) -> bool {\n        self.core.is_connected()\n    }\n\n    fn client_id(&self) -> ClientId {\n        self.core.client_id\n    }\n\n    fn account_id(&self) -> AccountId {","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/architect_ax/src/execution.rs#L386-L422","documentation":"During connect, the execution client spawns a query_account task (request_account_state -> account state event) and then polls the shared cache every 10ms for the account_id to appear, up to timeout_secs. This bail means no AccountState for that exact account_id was processed in time: the WebSocket/HTTP flow that publishes account state never delivered it. Orders cannot be accepted before the account exists in the cache, so startup aborts.","triggerScenarios":"The account_id resolved at client construction (from whoami) differs from what the account-state stream reports; the AX WebSocket is not connected or its subscription failed; request_account_state itself errored (check for a query_account failure in logs); timeout_secs configured too small for a slow first snapshot.","commonSituations":"API key whose account set changed on the venue after startup; WS endpoint blocked/down (proxy, heartbeat timeouts); heavily loaded engine where first event processing exceeds the configured timeout; custom timeout_secs lowered during tuning.","solutions":["Raise the account registration timeout in the exec config and retry connect","Check logs just before the bail for a failed query_account or WS error and fix that first (credentials, network, ws_public_url)","Confirm the whoami account for these credentials matches the account being awaited (account id mismatch = never registers)","If the WS is the problem, verify ws_public_url/heartbeat settings and proxy reachability"],"exampleFix":"// before\nlet config = AxExecClientConfig::builder()\n    .timeout_account_registration_secs(5.0) // too tight\n    .build()?;\n// after\nlet config = AxExecClientConfig::builder()\n    .timeout_account_registration_secs(30.0)\n    .build()?;","handlingStrategy":"retry","validationCode":"// Before starting the engine: confirm the account exists for these creds\nlet whoami = raw_client.get_whoami().await?;\nensure!(!whoami.accounts.is_empty(), \"key has no accounts\");","typeGuard":null,"tryCatchPattern":"// connect() returned Err(timeout): inspect cause, then one full reconnect\nmatch exec_connect_result {\n    Err(e) if e.to_string().contains(\"Timeout waiting for account\") => {\n        log::warn!(\"account registration timed out; reconnecting with longer timeout\");\n        increase_timeout_and_reconnect()?; // full WS + account-state retry\n    }\n    r => r,\n}","preventionTips":["Set timeout_account_registration_secs generously (>= 30s) for production startups","Watch for query_account errors in logs - they are the root cause, the timeout is only the symptom","Verify the whoami account id matches the account state stream once at first connect"],"tags":["architect-ax","connect","account-state","timeout","websocket","rust"],"backgroundTag":"startup-timeout","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}