nautechsystems/nautilus_trader · error · anyhow::Error

failed to create CLOB HTTP client

Error message

failed to create CLOB HTTP client

What it means

The Polymarket execution client constructor (`new`) builds a `PolymarketClobHttpClient` for the CLOB HTTP API using credentials, signer address, base URL, timeout, and optional proxy. Any failure from that client constructor is wrapped with this context. It indicates the CLOB HTTP client could not be constructed, so the execution client cannot be created.

Source

Thrown at crates/adapters/polymarket/src/execution/mod.rs:149

            config.passphrase.clone(),
            config.funder.clone(),
        )
        .context("failed to resolve Polymarket credentials")?;

        let signer_address = secrets.address.clone();
        let maker_address = resolve_maker_address(
            config.signature_type,
            &signer_address,
            secrets.funder.as_deref(),
        )?;
        let http_client = PolymarketClobHttpClient::new_with_proxy(
            secrets.credential.clone(),
            signer_address.clone(),
            config.base_url_http.clone(),
            config.http_timeout_secs,
            proxy_url.clone(),
        )
        .map_err(|e| anyhow::anyhow!("{e}"))
        .context("failed to create CLOB HTTP client")?;

        let data_api_client = PolymarketDataApiHttpClient::new_with_proxy(
            Some(config.data_api_url()),
            config.http_timeout_secs,
            proxy_url.clone(),
        )
        .map_err(|e| anyhow::anyhow!("{e}"))
        .context("failed to create Data API HTTP client")?;

        let order_signer =
            OrderSigner::new(&secrets.private_key).context("failed to create order signer")?;
        let order_builder = Arc::new(PolymarketOrderBuilder::new(
            order_signer,
            signer_address,
            maker_address,
            config.signature_type,
        ));

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify config.base_url_http is a valid absolute URL with scheme (e.g. https://clob.polymarket.com)
  2. Check proxy_url is a valid HTTP(S) proxy URL or None — include scheme and port
  3. Validate http_timeout_secs is a positive sane value
  4. Confirm credentials and signer_address from secrets are well-formed (0x-prefixed addresses)
  5. Read the inner `{e}` error for the exact constructor failure

Example fix

// before
http_timeout_secs: 0,
proxy_url: Some("proxy.corp:8080".into()), // missing scheme
// after
http_timeout_secs: 30,
proxy_url: Some("http://proxy.corp:8080".into()),
Defensive patterns

Strategy: validation

Validate before calling

fn validate_http_config(cfg: &PolymarketExecConfig) -> Result<(), String> {
    if !cfg.base_url_http.starts_with("http") { return Err("base_url_http must be an absolute URL".into()); }
    if cfg.http_timeout_secs == 0 { return Err("http_timeout_secs must be > 0".into()); }
    if let Some(p) = &cfg.proxy_url {
        if !p.starts_with("http") { return Err("proxy_url must include scheme".into()); }
    }
    Ok(())
}

Try / catch

let client = PolymarketExecutionClient::new(...)
    .map_err(|e| { tracing::error!("init: {e:#}"); e })?;

Prevention

When it happens

Trigger: Invalid base_url_http (unparseable URL); invalid credentials/signer address format; invalid http_timeout_secs; proxy_url that cannot be parsed or an unsupported proxy scheme passed to new_with_proxy.

Common situations: Misconfigured POLYMARKET_HTTP_URL or proxy env var (typo, missing scheme like http://); corporate proxy requiring auth; bad timeout value (0 or negative); malformed API credentials in secrets config.

Related errors


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