{"record":{"id":"d0407720b3c1360b","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-http-client-i-e-d04077","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/submitter.rs","lineNumber":451,"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-submit-{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_submits: Arc::new(AtomicU64::new(0)),\n            successful_submits: Arc::new(AtomicU64::new(0)),\n            failed_submits: Arc::new(AtomicU64::new(0)),\n            expected_rejects: Arc::new(AtomicU64::new(0)),\n        })\n    }\n\n    /// Starts the broadcaster and health check loop.\n    ///","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/broadcast/submitter.rs#L433-L469","documentation":"One of the BitMEX broadcast submitter's HTTP transport clients could not be constructed. During `new`, each transport builds an HTTP client with retry, rate-limit, recv-window and proxy settings; a failure for client index `{i}` is wrapped in this error, aborting submitter construction.","triggerScenarios":"Creating the BitMEX broadcast submitter and transport `{i}`'s HTTP client builder fails — invalid `proxy_url`, TLS/CA config error, or invalid rate-limit/retry parameters.","commonSituations":"Misconfigured proxy in the BitMEX submit config; missing CA certificates in a container; malformed max-requests-per-second/minute values; same root causes as the canceller's identical error.","solutions":["Inspect the wrapped `{e}` for the precise client-builder failure.","Validate `proxy_url` format (must include scheme, e.g. `http://host:port`).","Fix TLS/CA setup in the deployment environment (SSL_CERT_FILE, ca-certificates package).","Confirm retry/rate-limit config values are valid positive numbers."],"exampleFix":"// before\nproxy_url = Some(\"localhost:8888\".to_string());\n// after\nproxy_url = Some(\"http://localhost:8888\".to_string());","handlingStrategy":"validation","validationCode":"fn validate_submit_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, format!(\"bitmex-submit-{i}\"))),\n    Err(e) => return Err(e.context(\"bitmex submitter init failed\")),\n}","preventionTips":["Pre-flight validate proxy and rate-limit config before constructing the submitter.","Ensure TLS/CA certificates are present in the deployment image.","Share config validation logic between submitter and canceller so both fail consistently."],"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-14T05:17:10.506Z"}