nautechsystems/nautilus_trader · error

Architect AX orders WebSocket handler failed: {error}

Error message

Architect AX orders WebSocket handler failed: {error}

What it means

Returned by the Architect AX orders WebSocket client's close(). It mirrors the data client: when the joined orders handler task ended with TaskJoinOutcome::Failed, close() wraps that error in this message and returns it.

Source

Thrown at crates/adapters/architect_ax/src/websocket/orders/client.rs:751

        // Send disconnect first to allow graceful cleanup before signal
        self.cancellation_token.load().cancel();
        let _ = self.send_cmd(HandlerCommand::Disconnect).await;
        tokio::time::sleep(Duration::from_millis(50)).await;
        self.signal.store(true, Ordering::Release);

        let outcome = self
            .task_handle
            .finish(Duration::from_secs(2), Duration::from_secs(2))
            .await;
        *self.reconnect_headers.lock() = None;

        if let Some(control) = &self.socket_control {
            control.deregister();
        }

        match outcome {
            None | Some(TaskJoinOutcome::Completed(()) | TaskJoinOutcome::Aborted) => Ok(()),
            Some(TaskJoinOutcome::Failed(error)) => Err(anyhow::anyhow!(
                "Architect AX orders WebSocket handler failed: {error}"
            )),
            Some(TaskJoinOutcome::Incomplete) => Err(anyhow::anyhow!(
                "Architect AX orders WebSocket handler did not stop after abort"
            )),
        }
    }

    async fn send_cmd(&self, cmd: HandlerCommand) -> AxOrdersWsResult<()> {
        let guard = self.cmd_tx.read().await;
        guard
            .send(cmd)
            .map_err(|e| AxOrdersWsClientError::ChannelError(e.to_string()))
    }
}

impl Drop for AxOrdersWebSocketClient {
    fn drop(&mut self) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Read the wrapped inner error to identify the actual handler failure
  2. Check connectivity/auth to the Architect AX order gateway around the failure time
  3. Treat the Err as informational during teardown if the session is already ending (log instead of propagate)
  4. Fix the underlying handler bug if it reproduces with specific commands

Example fix

// before
orders.close().await?;
// after
if let Err(e) = orders.close().await {
    tracing::warn!("orders ws close: {e:#}");
}
Defensive patterns

Strategy: try-catch

Try / catch

// Rust
if let Err(e) = orders.close().await {
    tracing::warn!("orders ws handler failed on close: {e:#}");
}

Prevention

When it happens

Trigger: Calling OrdersWebSocketClient::close() when the internal orders handler task previously exited with an error — e.g. order-submit/cancel command handling failed, the upstream socket errored, or the handler returned Err.

Common situations: Order gateway connection broke during a session; a submit/cancel command channel error killed the handler; teardown after a handler failure in tests or on disconnect.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/c86ea2efda36ee59. Report an issue: GitHub.