nautechsystems/nautilus_trader · critical

Failed to create default AxRawHttpClient

Error message

Failed to create default AxRawHttpClient

What it means

AxRawHttpClient::default() delegates to new(None, None, 60, 3, 1000, 10_000, None) and unwraps the result with expect. If the constructor fails — typically because the default base URL cannot be parsed into a Url or a reqwest client cannot be built — the process panics with 'Failed to create default AxRawHttpClient'.

Source

Thrown at crates/adapters/architect_ax/src/http/client.rs:114

/// Raw HTTP client for low-level AX Exchange API operations.
///
/// This client handles request/response operations with the AX Exchange API,
/// returning venue-specific response types. It does not parse to Nautilus domain types.
pub struct AxRawHttpClient {
    base_url: String,
    orders_base_url: String,
    client: HttpClient,
    credential: Option<Credential>,
    session_token: RwLock<Option<SecretString>>,
    retry_manager: RetryManager<AxHttpError>,
    cancellation_token: RwLock<CancellationToken>,
}

impl Default for AxRawHttpClient {
    fn default() -> Self {
        Self::new(None, None, 60, 3, 1000, 10_000, None)
            .expect("Failed to create default AxRawHttpClient")
    }
}

impl Debug for AxRawHttpClient {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let has_session_token = self.session_token.read().is_some();
        f.debug_struct(stringify!(AxRawHttpClient))
            .field("base_url", &self.base_url)
            .field("orders_base_url", &self.orders_base_url)
            .field("has_credentials", &self.credential.is_some())
            .field("has_session_token", &has_session_token)
            .finish()
    }
}

impl AxRawHttpClient {
    /// Returns the base URL for this client.
    #[must_use]

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Replace AxRawHttpClient::default() with an explicit new(...) call and handle the returned Result instead of expecting success.
  2. Pass an explicit valid base URL (and credentials) via new() rather than relying on the built-in default.
  3. Check reqwest/TLS feature flags of the build (rustls vs native-tls) if client construction fails at startup.
  4. If this appears after an adapter upgrade, check the release notes for a changed default URL constant.

Example fix

// before
let client = AxRawHttpClient::default(); // panics on failure
// after
let client = AxRawHttpClient::new(None, None, 60, 3, 1000, 10_000, None)
    .unwrap_or_else(|e| panic!("init AxRawHttpClient failed: {e}")); // or propagate Err
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify reqwest/TLS features are enabled in Cargo.toml and the default URL parses before relying on Default
assert!(url::Url::parse(DEFAULT_AX_HTTP_URL).is_ok(), "default AX URL invalid");

Try / catch

// Default() panics; avoid it. Use new() and handle Result:
let client = AxRawHttpClient::new(None, None, 60, 3, 1000, 10_000, None)
    .map_err(|e| anyhow!("AxRawHttpClient init failed: {e}"))?;

Prevention

When it happens

Trigger: Calling AxRawHttpClient::default() (or new with None URL) when the built-in default AX HTTP URL string fails to parse, or reqwest::Client::builder construction fails (e.g. TLS backend initialization failure).

Common situations: Running in an environment where the TLS/runtime backend fails to initialize; a renamed or malformed default URL constant after an adapter upgrade; using the Default impl in constrained environments (static binaries without proper TLS roots) instead of new() with explicit arguments.

Related errors


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