nautechsystems/nautilus_trader · error · anyhow::Error

ws_trading_setup_timeout_ms must be greater than 0, was

Error message

ws_trading_setup_timeout_ms must be greater than 0, was {}

What it means

ws_trading_setup_timeout_ms bounds the time allowed for the WebSocket trading connection to become ready. validate() requires a strictly positive value because a zero timeout would make the setup phase fail immediately/non-deterministically.

Solutions

  1. Set ws_trading_setup_timeout_ms to a positive value, e.g. 10_000 (10 seconds).
  2. Check where the value is loaded from (env/config file) and provide a sensible default instead of 0.
  3. Confirm the unit is milliseconds, not seconds.

Example fix

// before
let config = BinanceDataClientConfig { ws_trading_setup_timeout_ms: 0, .. };
// after
let config = BinanceDataClientConfig { ws_trading_setup_timeout_ms: 10_000, .. };
Defensive patterns

Strategy: validation

Validate before calling

fn setup_timeout_ok(ms: u64) -> bool { ms > 0 }

Prevention

When it happens

Trigger: Constructing the Binance client config with ws_trading_setup_timeout_ms set to 0 (e.g. from an env var defaulting to 0 or a typo) and calling validate().

Common situations: Environment variable parsed as milliseconds defaulting to 0 when unset; misreading the field as a boolean flag or seconds; copy-paste leaving the field at its zero-valued default.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/config.rs:429

    transport_backend: TransportBackend,
});

impl Default for BinanceExecutionClientConfig {
    fn default() -> Self {
        Self::builder().build()
    }
}

impl BinanceExecutionClientConfig {
    /// Validates Binance execution client configuration.
    ///
    /// # Errors
    ///
    /// Returns an error for invalid receive-window, WS trading setup timeout, provider, or
    /// Binance US settings.
    pub fn validate(&self) -> anyhow::Result<()> {
        validate_recv_window(self.recv_window_ms)?;
        anyhow::ensure!(
            self.ws_trading_setup_timeout_ms > 0,
            "ws_trading_setup_timeout_ms must be greater than 0, was {}",
            self.ws_trading_setup_timeout_ms
        );
        self.instrument_provider.validate(self.product_type)?;

        if self.us {
            anyhow::ensure!(
                self.product_type == BinanceProductType::Spot,
                "Binance US supports Spot clients only"
            );
            anyhow::ensure!(
                self.environment == BinanceEnvironment::Live,
                "Binance US supports the Live environment only"
            );
        }

        Ok(())

View on GitHub (pinned to 18893faf8b)