{"record":{"id":"c18d3d287dae695e","repo":"nautechsystems/nautilus_trader","slug":"blockchain-execution-client-is-not-connected","errorCode":null,"errorMessage":"Blockchain execution client is not connected","messagePattern":"Blockchain execution client is not connected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1522,"sourceCode":"\n        match purpose {\n            TransactionPurpose::Wrap => {\n                verify_wrap_balance_increase(executor, &to, value, included).await\n            }\n            TransactionPurpose::Approve => {\n                let call = ERC20::approveCall::abi_decode(&input)\n                    .with_context(|| \"persisted approve calldata is invalid\")?;\n                verify_approve_allowance(executor, &to, &call.spender, call.amount, included).await\n            }\n            TransactionPurpose::Swap => {\n                unreachable!(\"swap intents restore a swap plan\")\n            }\n        }\n    }\n\n    fn ensure_transaction_ready(&self, purpose: TransactionPurpose) -> anyhow::Result<()> {\n        if !self.core.is_connected() {\n            anyhow::bail!(\"Blockchain execution client is not connected\");\n        }\n\n        {\n            let slot = self.in_flight.lock();\n            if let Some(in_flight) = *slot {\n                return Err(in_flight_limit_error(&in_flight));\n            }\n        }\n\n        if !self.cache.has_database() {\n            anyhow::bail!(\n                \"No durable store configured; refusing to submit a {} transaction\",\n                purpose.as_str()\n            );\n        }\n        Ok(())\n    }\n","sourceCodeStart":1504,"sourceCodeEnd":1540,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1504-L1540","documentation":"ensure_transaction_ready() is the pre-flight gate for submitting any transaction (wrap, approve, swap). It first requires the execution client to be connected to the chain via core.is_connected(); if not, it fails closed so no transaction is signed or submitted while the client is offline.","triggerScenarios":"Calling wrap(), approve(), or prepare_swap() (e.g. via submit_order) before connect() succeeded, or after the connection dropped/was closed (RPC endpoint down, network interruption, client explicitly disconnected).","commonSituations":"Submitting an order at startup before the async connect completed; RPC provider outage or WebSocket disconnect mid-session; calling wrap/approve on a fresh client without connecting; a dropped network causing is_connected() to flip false while the strategy keeps trading.","solutions":["Await a successful connect() (and any required post-connect reconciliation) before calling wrap, approve, or submit_order.","Check connection state (client.is_connected()) in your strategy loop and gate order submission on it.","Verify the RPC endpoint/URL and network reachability, then reconnect; re-establish the WebSocket/HTTP provider if it dropped.","Handle the not-connected error by pausing trading and retrying connect with backoff instead of resubmitting transactions."],"exampleFix":"// before: submit immediately, fails if not yet connected\nclient.submit_order(order)?;\n\n// after: gate on connection before trading\nif !client.is_connected() {\n    client.connect().await.expect(\"execution client connect\");\n}\nassert!(client.is_connected());\nclient.submit_order(order)?;","handlingStrategy":"try-catch","validationCode":"// Gate submission on connection state before calling wrap/approve/submit_order\nif !client.is_connected() {\n    client.connect().await?; // or defer submission until connected\n}","typeGuard":null,"tryCatchPattern":"match client.submit_order(order) {\n    Err(e) if e.to_string().contains(\"not connected\") => {\n        log::warn!(\"execution client offline; pausing trading\");\n        client.connect().await?; // reconnect with backoff, then resubmit\n    }\n    result => result?,\n}","preventionTips":["Await connect() (and post-connect reconciliation) completion before enabling order submission.","Subscribe to connection-state changes and pause trading on disconnect.","Configure RPC reconnect/backoff and health checks so is_connected() recovers promptly.","Use a connection watchdog that reconnects automatically during provider outages."],"tags":["blockchain","connection","rpc","lifecycle"],"backgroundTag":"connection-refused","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"}