{"record":{"id":"b2a5573e61c76c47","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-http-client-i-e","errorCode":null,"errorMessage":"Failed to create HTTP client {i}: {e}","messagePattern":"Failed to create HTTP client (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/broadcast/canceller.rs","lineNumber":403,"sourceCode":"                .proxy_urls\n                .get(i)\n                .and_then(|value| value.as_ref())\n                .map(|value| value.expose_secret().to_owned());\n\n            let client = BitmexHttpClient::with_credentials(\n                config.api_key.clone().map(SecretString::into_inner),\n                config.api_secret.clone().map(SecretString::into_inner),\n                base_url.clone(),\n                config.timeout_secs,\n                config.max_retries,\n                config.retry_delay_ms,\n                config.retry_delay_max_ms,\n                config.recv_window_ms,\n                config.max_requests_per_second,\n                config.max_requests_per_minute,\n                proxy_url,\n            )\n            .map_err(|e| anyhow::anyhow!(\"Failed to create HTTP client {i}: {e}\"))?;\n\n            transports.push(TransportClient::new(client, format!(\"bitmex-cancel-{i}\")));\n        }\n\n        Ok(Self {\n            config,\n            transports: Arc::from(transports),\n            health_check_task: Arc::new(RwLock::new(None)),\n            running: Arc::new(AtomicBool::new(false)),\n            total_cancels: Arc::new(AtomicU64::new(0)),\n            successful_cancels: Arc::new(AtomicU64::new(0)),\n            failed_cancels: Arc::new(AtomicU64::new(0)),\n            expected_rejects: Arc::new(AtomicU64::new(0)),\n            idempotent_successes: Arc::new(AtomicU64::new(0)),\n        })\n    }\n\n    /// Starts the broadcaster and health check loop.","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/broadcast/canceller.rs#L385-L421","documentation":"One of the BitMEX broadcast canceller's HTTP transport clients could not be constructed. During `new`, each configured transport builds an HTTP client (with retry, rate limits, recv window, proxy); a failure on client index `{i}` (invalid proxy URL, bad TLS backend config, etc.) is wrapped in this error.","triggerScenarios":"Instantiating the BitMEX broadcast canceller with `N` transports and transport `{i}`'s HTTP client builder fails — typically due to an invalid `proxy_url`, an unusable TLS/CA configuration, or an invalid rate-limit/retry parameter.","commonSituations":"Corporate proxy URL malformed or unreachable at startup; missing/invalid CA bundle in the container; bad config values (e.g. zero or negative max requests) rejected by the client builder.","solutions":["Check the inner `{e}` message — it names the exact client-builder failure.","Validate `proxy_url` in the BitMEX cancel config (must be a full URL like `http://host:port`).","Ensure the CA/TLS environment is correct (e.g. set SSL_CERT_FILE / install ca-certificates in the container).","Verify rate-limit and retry config values are sane positive integers."],"exampleFix":"// before\nproxy_url = Some(\"proxy.internal:8080\".to_string());\n// after\nproxy_url = Some(\"http://proxy.internal:8080\".to_string());","handlingStrategy":"try-catch","validationCode":"fn validate_http_config(proxy_url: &Option<String>, max_rps: u32, max_rpm: u32) -> Result<(), String> {\n    if let Some(url) = proxy_url {\n        url::Url::parse(url).map_err(|e| format!(\"invalid proxy_url '{url}': {e}\"))?;\n    }\n    if max_rps == 0 || max_rpm == 0 {\n        return Err(\"rate limits must be > 0\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match HttpClient::new(...).map_err(|e| anyhow::anyhow!(\"Failed to create HTTP client {i}: {e}\")) {\n    Ok(client) => transports.push(TransportClient::new(client, name)),\n    Err(e) => return Err(e.context(\"bitmex canceller init failed\")),\n}","preventionTips":["Validate proxy URLs include scheme and port before startup.","Install CA certificates in containers running the adapter.","Fail fast with a config pre-flight check when deploying."],"tags":["http-client","initialization","bitmex","proxy","rust"],"backgroundTag":"module-init-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}