{"record":{"id":"dc92ac416227c760","repo":"nautechsystems/nautilus_trader","slug":"wss-rpc-url-is-required","errorCode":null,"errorMessage":"wss_rpc_url is required","messagePattern":"wss_rpc_url is required","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/data/core.rs","lineNumber":187,"sourceCode":"    #[must_use]\n    pub fn new(\n        config: BlockchainDataClientConfig,\n        hypersync_tx: Option<tokio::sync::mpsc::UnboundedSender<BlockchainMessage>>,\n        data_tx: Option<tokio::sync::mpsc::UnboundedSender<DataEvent>>,\n        cancellation_token: tokio_util::sync::CancellationToken,\n    ) -> Self {\n        let chain = config.chain.clone();\n        let cache = BlockchainCache::new(chain.clone());\n\n        // Log RPC endpoints being used\n        log::debug!(\n            \"Initializing blockchain data client for '{}' with HTTP RPC: {}\",\n            chain.name,\n            REDACTED\n        );\n\n        let rpc_client = if !config.use_hypersync_for_live_data && config.wss_rpc_url.is_some() {\n            let wss_rpc_url = config.wss_rpc_url.clone().expect(\"wss_rpc_url is required\");\n            log::debug!(\"WebSocket RPC URL: {REDACTED}\");\n            Some(Self::initialize_rpc_client(\n                chain.name,\n                wss_rpc_url.into_inner(),\n                config.transport_backend,\n                config.proxy_url.clone().map(|value| value.into_inner()),\n            ))\n        } else {\n            log::debug!(\"Using HyperSync for live data (no WebSocket RPC)\");\n            None\n        };\n        let http_rpc_client = Arc::new(BlockchainHttpRpcClient::new(\n            config.http_rpc_url.clone().into_inner(),\n            config.rpc_requests_per_second,\n            config.proxy_url.clone().map(|value| value.into_inner()),\n        ));\n        let multicall_calls_per_rpc_request = config.multicall_calls_per_rpc_request;\n        let erc20_contract = Erc20Contract::new(","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/data/core.rs#L169-L205","documentation":"BlockchainDataClientCore::new reads `config.wss_rpc_url` when live WebSocket data is enabled (not using HyperSync) and unwraps it with `expect(\"wss_rpc_url is required\")`. The guard `config.wss_rpc_url.is_some()` makes the panic nearly unreachable, but it documents that a WebSocket URL is mandatory on this path — a None here is a config/invariant violation.","triggerScenarios":"Constructing the client with `use_hypersync_for_live_data = false` and `wss_rpc_url = None` (or a config that deserializes it as None while another thread mutates it), reaching the `.expect` on the cloned Option.","commonSituations":"Config file or env omitting the WSS RPC URL while live-data mode requires it; typo'd config key so the field defaults to None; config builder leaving the optional field unset.","solutions":["Set `wss_rpc_url` (e.g. `wss://mainnet.infura.io/ws/v3/<key>`) in the client config when HyperSync live data is disabled.","Alternatively enable `use_hypersync_for_live_data = true` so the WSS URL is not required.","Check the config key spelling/section so the URL actually deserializes into `wss_rpc_url`.","Validate the config (wss URL present iff not using HyperSync) before calling `new`."],"exampleFix":"// before\nlet config = BlockchainDataClientConfig {\n    use_hypersync_for_live_data: false,\n    wss_rpc_url: None, // panics in new()\n    ..Default::default()\n};\n// after\nlet config = BlockchainDataClientConfig {\n    use_hypersync_for_live_data: false,\n    wss_rpc_url: Some(SecretString::from(\"wss://mainnet.infura.io/ws/v3/<key>\".to_string())),\n    ..Default::default()\n};","handlingStrategy":"validation","validationCode":"if !config.use_hypersync_for_live_data && config.wss_rpc_url.is_none() {\n    return Err(anyhow!(\"wss_rpc_url is required when use_hypersync_for_live_data is false\"));\n}","typeGuard":"fn wss_ready(config: &BlockchainDataClientConfig) -> bool {\n    config.use_hypersync_for_live_data || config.wss_rpc_url.is_some()\n}","tryCatchPattern":"// Rust: check the option yourself before constructing\nlet wss = match (&config.use_hypersync_for_live_data, &config.wss_rpc_url) {\n    (false, Some(url)) => Some(url.clone()),\n    (false, None) => return Err(anyhow!(\"wss_rpc_url is required\")),\n    (true, _) => None,\n};","preventionTips":["Always set wss_rpc_url when live WebSocket data is enabled (HyperSync disabled).","Set use_hypersync_for_live_data = true if you do not have a WSS endpoint.","Validate the client config (required fields per mode) before calling `new`.","Check config key spelling and sections so values actually deserialize."],"tags":["config","websocket","missing-config","panic"],"backgroundTag":"missing-required-config-field","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"}