pub struct WsConfig {
pub url: String,
pub connect_timeout: u64,
pub ping_interval: u64,
pub reconnect_interval: u64,
pub max_reconnect_attempts: u32,
pub auto_reconnect: bool,
pub enable_compression: bool,
pub pong_timeout: u64,
pub backoff_config: BackoffConfig,
pub max_subscriptions: usize,
pub shutdown_timeout: u64,
}Expand description
WebSocket connection configuration.
This struct contains all configuration options for WebSocket connections, including connection timeouts, reconnection behavior, and resource limits.
§Example
use ccxt_core::ws_client::{WsConfig, BackoffConfig};
use std::time::Duration;
let config = WsConfig {
url: "wss://stream.example.com/ws".to_string(),
max_subscriptions: 50,
backoff_config: BackoffConfig {
base_delay: Duration::from_millis(500),
max_delay: Duration::from_secs(30),
..Default::default()
},
..Default::default()
};Fields§
§url: StringWebSocket server URL
connect_timeout: u64Connection timeout in milliseconds
ping_interval: u64Ping interval in milliseconds
reconnect_interval: u64Reconnection delay in milliseconds (legacy, use backoff_config for exponential backoff)
max_reconnect_attempts: u32Maximum reconnection attempts before giving up
auto_reconnect: boolEnable automatic reconnection on disconnect
enable_compression: boolEnable message compression
pong_timeout: u64Pong timeout in milliseconds
Connection is considered dead if no pong received within this duration.
backoff_config: BackoffConfigExponential backoff configuration for reconnection.
This configuration controls how retry delays are calculated during reconnection attempts. Uses exponential backoff with jitter to prevent thundering herd effects.
§Default
base_delay: 1 secondmax_delay: 60 secondsjitter_factor: 0.25 (25%)multiplier: 2.0
max_subscriptions: usizeMaximum number of subscriptions allowed.
When this limit is reached, new subscription attempts will fail with
Error::ResourceExhausted. This prevents resource exhaustion from
too many concurrent subscriptions.
§Default
100 subscriptions (see DEFAULT_MAX_SUBSCRIPTIONS)
shutdown_timeout: u64Shutdown timeout in milliseconds.
Maximum time to wait for pending operations to complete during graceful shutdown. After this timeout, the shutdown will proceed regardless of pending operations.
§Default
5000 milliseconds (5 seconds)