nautechsystems/nautilus_trader · error

Failed to create Coinbase HTTP client: {e}

Error message

Failed to create Coinbase HTTP client: {e}

What it means

The execution client's `new` builds an authenticated CoinbaseHttpClient with the resolved credentials, environment, timeout, proxy, and retry settings. If the client builder fails, the error is wrapped as 'Failed to create Coinbase HTTP client'.

Source

Thrown at crates/adapters/coinbase/src/execution.rs:175

        let retry_config = RetryConfig {
            max_retries: config.max_retries,
            initial_delay_ms: config.retry_delay_initial_ms,
            max_delay_ms: config.retry_delay_max_ms,
            backoff_factor: 2.0,
            jitter_ms: 250,
            operation_timeout_ms: Some(60_000),
            immediate_first: false,
            max_elapsed_ms: Some(180_000),
        };

        let http_client = CoinbaseHttpClient::with_credentials(
            credential.clone(),
            config.environment,
            config.http_timeout_secs,
            proxy_url.clone(),
            Some(retry_config),
        )
        .map_err(|e| anyhow::anyhow!("Failed to create Coinbase HTTP client: {e}"))?;

        if let Some(ref url) = config.base_url_rest {
            http_client.set_base_url(url.clone());
        }

        let ws_url = config.ws_url();
        let ws_user = CoinbaseWebSocketClient::with_credential(
            &ws_url,
            credential,
            config.transport_backend,
            proxy_url,
        )
        .with_socket_control(SocketControl::new(
            core.client_id,
            Some(*COINBASE_VENUE),
            "coinbase-user-streams",
        ));

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Read the wrapped `{e}` for the concrete cause
  2. Match config.environment to the environment the credentials were issued for
  3. Validate proxy_url format or unset it
  4. Check api_key/api_secret are correctly formatted (no whitespace/newlines)
  5. Use default timeout/retry settings to rule out bad config values

Example fix

// before
config.environment = CoinbaseEnvironment::Sandbox; // keys are production
// after
config.environment = CoinbaseEnvironment::Live;
Defensive patterns

Strategy: validation

Validate before calling

if config.api_key.as_deref().map_or(false, |k| k.trim() != k) {
    return Err("api_key has surrounding whitespace");
}
if let Some(p) = &config.proxy_url {
    url::Url::parse(p).map_err(|e| format!("bad proxy: {e}"))?;
}

Prevention

When it happens

Trigger: Constructing the execution client with credentials that cause the authenticated HTTP client build to fail — e.g. malformed proxy_url, invalid environment, invalid timeout/retry configuration, or credential format rejected during client setup.

Common situations: Wrong environment enum for the credential type (e.g. production keys with a sandbox environment), invalid proxy URL, misconfigured retry policy.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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