{"record":{"id":"a5919561e965bbe5","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-http-client-e","errorCode":null,"errorMessage":"Failed to create HTTP client: {e}","messagePattern":"Failed to create HTTP client: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/factories.rs","lineNumber":118,"sourceCode":"        let client_id = ClientId::from(name);\n\n        let http_client = if ax_config.has_api_credentials() {\n            let credential =\n                Credential::resolve(ax_config.api_key.clone(), ax_config.api_secret.clone())\n                    .ok_or_else(|| anyhow::anyhow!(\"API credentials not configured\"))?;\n\n            AxHttpClient::with_credentials(\n                credential.api_key().to_string(),\n                credential.api_secret().to_string(),\n                Some(ax_config.http_base_url()),\n                None, // orders_base_url\n                ax_config.http_timeout_secs,\n                ax_config.max_retries,\n                ax_config.retry_delay_initial_ms,\n                ax_config.retry_delay_max_ms,\n                ax_config.proxy_url.clone(),\n            )\n            .map_err(|e| anyhow::anyhow!(\"Failed to create HTTP client: {e}\"))?\n        } else {\n            AxHttpClient::new(\n                Some(ax_config.http_base_url()),\n                None, // orders_base_url\n                ax_config.http_timeout_secs,\n                ax_config.max_retries,\n                ax_config.retry_delay_initial_ms,\n                ax_config.retry_delay_max_ms,\n                ax_config.proxy_url.clone(),\n            )\n            .map_err(|e| anyhow::anyhow!(\"Failed to create HTTP client: {e}\"))?\n        };\n\n        let ws_url = ax_config.ws_public_url();\n\n        // Token set during connect\n        let ws_client = AxMdWebSocketClient::without_auth(\n            ws_url,","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/architect_ax/src/factories.rs#L100-L136","documentation":"The authenticated branch of the data-client factory: building the underlying HTTP stack (AxHttpClient::with_credentials -> HttpClient::new with headers, rate-limiter quotas, timeout and optional proxy) returned Err, re-wrapped as AxHttpError::NetworkError(\"Failed to create HTTP client: ...\") and surfaced with this anyhow context. Construction-time failures are local, not venue responses: typically an invalid proxy_url, a TLS/connector initialization failure, or a misbuilt client runtime.","triggerScenarios":"AxDataClientConfig with proxy_url set to a malformed URL or unreachable proxy scheme; TLS backend problems in the build (missing rustls/native-tls features); exotic runtime configurations where the HTTP connector cannot initialize. Happens with valid credentials - it fails before any request is sent.","commonSituations":"Corporate-proxy deployments where proxy_url was typo'd (missing scheme, bad port); hardened containers missing CA bundles; feature-flag mismatches after editing the crate's Cargo features.","solutions":["Check the inner {e}: 'proxy' errors -> fix/remove proxy_url in the config; TLS errors -> check build features and CA store","Retry with proxy_url: None to isolate whether the proxy is the cause","Validate the proxy URL parses (reqwest::Proxy::all) before passing it into config","Confirm the same config works in a plain environment (no proxy env vars like HTTPS_PROXY leaking in)"],"exampleFix":"// before\nlet cfg = AxDataClientConfig::builder()\n    .proxy_url(Some(\"localhost:8080\".into())) // missing scheme -> client build fails\n    .build()?;\n// after\nlet cfg = AxDataClientConfig::builder()\n    .proxy_url(Some(\"http://localhost:8080\".into()))\n    .build()?;","handlingStrategy":"validation","validationCode":"// Validate the proxy URL before handing it to the config\nif let Some(proxy) = &config.proxy_url {\n    reqwest::Proxy::all(proxy.as_str())\n        .with_context(|| format!(\"invalid proxy_url: {proxy}\"))?;\n}","typeGuard":null,"tryCatchPattern":"match AxDataClientFactory.create(...) {\n    Err(e) if e.to_string().contains(\"Failed to create HTTP client\") => {\n        log::error!(\"local HTTP stack init failed: {e:#}\"); // do not retry unchanged config\n        Err(e)\n    }\n    r => r,\n}","preventionTips":["Always include the scheme in proxy_url (http:// or https:// or socks5://)","Clear stray HTTPS_PROXY/HTTP_PROXY/ALL_PROXY env vars in deployment manifests unless intended","Smoke-test client construction in CI with and without proxy configured"],"tags":["architect-ax","http-client","proxy","tls","factory","rust"],"backgroundTag":"http-client-init-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}