{"record":{"id":"1dc5859333d46605","repo":"nautechsystems/nautilus_trader","slug":"actor-actor-id-has-not-been-registered-with-a-tr","errorCode":null,"errorMessage":"Actor {actor_id} has not been registered with a Trader","messagePattern":"Actor (.+?) has not been registered with a Trader","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/actor/data_actor.rs","lineNumber":5753,"sourceCode":"            .register_response_handler(command.request_id(), handler)?;\n\n        self.send_data_cmd(DataCommand::Request(command));\n\n        Ok(request_id)\n    }\n\n    /// Sends a fire-and-observe reconnect command.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the actor is not registered, the endpoint label is invalid, the live\n    /// runner is unavailable, or the command channel is closed.\n    #[cfg(feature = \"live\")]\n    pub fn reconnect_socket(&self, client_id: ClientId, endpoint: &str) -> anyhow::Result<()> {\n        let endpoint = socket_endpoint(endpoint)?;\n\n        if !self.is_properly_registered() {\n            anyhow::bail!(\n                \"Actor {} has not been registered with a Trader\",\n                self.actor_id\n            );\n        }\n\n        let sender = try_get_system_command_sender()\n            .ok_or_else(|| anyhow::anyhow!(\"Live runner system command channel is unavailable\"))?;\n        let trader_id = self\n            .trader_id\n            .ok_or_else(|| anyhow::anyhow!(\"Actor {} has no trader ID\", self.actor_id))?;\n        let command = ReconnectSocket::new(trader_id, client_id, endpoint, self.timestamp_ns());\n        sender\n            .send(SystemCommand::ReconnectSocket(command))\n            .map_err(|_| anyhow::anyhow!(\"Live runner system command channel is closed\"))?;\n        Ok(())\n    }\n\n    #[cfg(test)]","sourceCodeStart":5735,"sourceCodeEnd":5771,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/actor/data_actor.rs#L5735-L5771","documentation":"`reconnect_socket` sends a system command through the actor's registered system-command sender. This plumbing only exists once the actor is registered with a Trader; if `is_properly_registered()` is false, the call bails because it cannot route the reconnect command.","triggerScenarios":"Calling `actor.reconnect_socket(client_id, endpoint)` on a DataActor before `register(trader_id, clock, cache)` completed; after registration was rolled back or in a standalone/unregistered actor context.","commonSituations":"Live trading setup where socket reconnect logic runs from a startup hook before trader registration; reusing an actor outside a Trader; reconnect triggered from a callback path when registration failed earlier.","solutions":["Ensure the actor is registered with a Trader before reconnecting sockets","Move reconnect logic into a post-registration lifecycle stage (e.g. on_start)","Validate `is_properly_registered()` and defer/queue the reconnect until registration completes"],"exampleFix":"// before\nactor.reconnect_socket(client_id, endpoint)?;\n// after\nif actor.is_properly_registered() {\n    actor.reconnect_socket(client_id, endpoint)?;\n} else {\n    log::warn!(\"skipping reconnect: actor not registered\");\n}","handlingStrategy":"validation","validationCode":"if !actor.is_properly_registered() {\n    log::warn!(\"reconnect_socket deferred: actor not registered\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = actor.reconnect_socket(client_id, &endpoint) {\n    if e.to_string().contains(\"not been registered\") {\n        // queue reconnect for after registration\n    } else { return Err(e); }\n}","preventionTips":["Only call live-only APIs from post-registration lifecycle hooks (on_start)","Never invoke reconnect from constructors or pre-registration setup","Check is_properly_registered before any system-command send"],"tags":["actor","live","socket","registration"],"backgroundTag":"invalid-state-transition","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"}