nautechsystems/nautilus_trader · error · anyhow::Error

WS modify order failed: {e}

Error message

WS modify order failed: {e}

What it means

When WebSocket order entry is active (config use_ws_trading with USD-M futures), modify requests are sent over the trading socket via modify_order_with_id. If that request fails — socket not yet connected, dropped mid-flight, timeout awaiting the response, or an error returned by the WS API — the adapter removes the pending-request entry, logs the failure, and raises this error from the spawned task. The order itself is left unmodified pending reconciliation.

Source

Thrown at crates/adapters/binance/src/futures/execution.rs:2872

                request_id.clone(),
                PendingRequest {
                    client_order_id: command.client_order_id,
                    venue_order_id,
                    operation: PendingOperation::Modify,
                },
            );

            self.spawn_task("modify_order_ws", async move {
                if let Err(e) = ws_client
                    .modify_order_with_id(request_id.clone(), params)
                    .await
                {
                    dispatch_state.pending_requests.remove(&request_id);
                    log::error!(
                        "WS modify request failed for {}: {e}",
                        command.client_order_id
                    );
                    anyhow::bail!("WS modify order failed: {e}");
                }
                Ok(())
            });

            return Ok(());
        }

        self.spawn_task("modify_order", async move {
            let result = http_client
                .modify_order(
                    account_id,
                    instrument_id,
                    venue_order_id,
                    client_order_id,
                    order_side,
                    quantity,
                    price,
                )

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Retry the modify once the WS connection is healthy — verify via connection logs/status
  2. Set use_ws_trading=false in BinanceExecClientConfig to route modifies over REST HTTP instead
  3. Query the order state first (QueryOrder) to confirm it is still open before re-modifying
  4. If persistent, inspect the underlying {e} and check Binance futures WS API status

Example fix

// before — WebSocket order entry enabled (default)
let config = BinanceExecClientConfigBuilder::default()
    .use_ws_trading(true)
    .build()?;

// after — route modify/cancel over REST
let config = BinanceExecClientConfigBuilder::default()
    .use_ws_trading(false)
    .build()?;
Defensive patterns

Strategy: fallback

Try / catch

Handle the error where modify results surface: verify current order state with QueryOrder, then either retry after the trading socket reconnects or resubmit the modify over REST (set use_ws_trading=false).

Prevention

When it happens

Trigger: ModifyOrder while ws trading is enabled and modify_order_with_id errors: connection not established yet, disconnect/reconnect window, response timeout, or a WS API rejection of the modify payload.

Common situations: Unstable networks; modifies issued immediately after startup before the WS session is ready; Binance WS maintenance windows; rate limiting on the order-entry connection.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/996891e3b85e4991. Report an issue: GitHub.