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
- Retry the modify once the WS connection is healthy — verify via connection logs/status
- Set use_ws_trading=false in BinanceExecClientConfig to route modifies over REST HTTP instead
- Query the order state first (QueryOrder) to confirm it is still open before re-modifying
- 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
- Wait for WS trading connection establishment before sending modifications
- Set use_ws_trading=false in BinanceExecClientConfig on unstable networks to use REST order entry
- Monitor pending-request cleanup and reconnect logs on the trading socket
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
- Modify order failed: {e}
- Either venue_order_id or client_order_id must be provided
- Invalid venue order ID
- failed to connect Binance Futures market WebSocket: {e}
- failed to connect Binance Futures public WebSocket: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/996891e3b85e4991.
Report an issue: GitHub.