nautechsystems/nautilus_trader · error
Failed to create HTTP client: {e}
Error message
Failed to create HTTP client: {e} What it means
Raised by the unauthenticated DeribitHttpClient constructor when HttpClient::builder()...build() fails. The builder error is wrapped via anyhow with the message 'Failed to create HTTP client: {e}'. This happens before any network traffic, i.e. the client could not even be constructed from its settings.
Source
Thrown at crates/adapters/deribit/src/http/client.rs:228
max_delay_ms: retry_delay_max_ms,
backoff_factor: 2.0,
jitter_ms: 1000,
operation_timeout_ms: Some(60_000),
immediate_first: false,
max_elapsed_ms: Some(180_000),
};
let retry_manager = RetryManager::new(retry_config);
Ok(Self {
base_url,
client: HttpClient::builder()
.keyed_quotas(Self::rate_limiter_quotas())
.default_quota(*DERIBIT_HTTP_REST_QUOTA)
.timeout_secs(timeout_secs)
.maybe_proxy_url(proxy_url)
.build()
.map_err(|e| anyhow::anyhow!("Failed to create HTTP client: {e}"))?,
credential: None,
retry_manager,
cancellation_token: CancellationToken::new(),
request_id: AtomicU64::new(1),
})
}
/// Get the cancellation token for this client.
pub fn cancellation_token(&self) -> &CancellationToken {
&self.cancellation_token
}
/// Returns whether this client is connected to testnet.
#[must_use]
pub fn is_testnet(&self) -> bool {
self.base_url.contains("test.")
}
View on GitHub (pinned to 18893faf8b)
Solutions
- Read the inner builder error after the colon — it names the invalid setting; correct that specific value.
- Validate the proxy URL is a well-formed http(s)://host:port string before constructing the client (or pass None).
- Ensure timeout_secs is a positive integer and reconsider any custom quota configuration from rate_limiter_quotas().
Example fix
// before
let client = DeribitHttpClient::new(timeout_secs=0, proxy_url=Some("localhost:9222".into()))?;
// after
let client = DeribitHttpClient::new(timeout_secs=30, proxy_url=Some("http://localhost:9222".into()))?; Defensive patterns
Strategy: validation
Validate before calling
fn validate_http_client_inputs(timeout_secs: u64, proxy_url: &Option<String>) -> Result<(), String> {
if timeout_secs == 0 { return Err("timeout_secs must be > 0".into()); }
if let Some(url) = proxy_url {
url::Url::parse(url).map_err(|e| format!("invalid proxy url: {e}"))?;
}
Ok(())
} Try / catch
let client = DeribitHttpClient::new(timeout_secs, proxy_url)
.with_context(|| format!("constructing Deribit HTTP client (timeout={timeout_secs}, proxy={proxy_url:?})"))?; Prevention
- Parse and validate proxy URLs at config-load time, before client construction.
- Keep timeout values as constants or validated config fields, never ad-hoc literals like 0.
- When upgrading the adapter, read the changelog for stricter HTTP client builder validation.
When it happens
Trigger: DeribitHttpClient::new(...) / with_proxy(...) when builder options are invalid: bad proxy_url format, invalid timeout_secs (e.g. zero or non-positive), or conflicting rate-limiter quota configuration in rate_limiter_quotas().
Common situations: Passing a malformed DERIBIT proxy URL from an environment variable; constructing the client with timeout_secs=0; a library version change that made previously-tolerated builder values invalid.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Instrument {instrument_id} not found and `auto_load_missing_
- Failed to create HTTP client: {e}
- Unsupported blockchain {blockchain} for RPC connection
- InstrumentState channel requires kind and currency parameter
- Kraken Spot does not support the demo environment
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1ddb8a6f3bd457fe.
Report an issue: GitHub.