{"record":{"id":"b9e5d6f9f1f0bda4","repo":"BigPizzaV3/CodexPlusPlus","slug":"cdp-websocket-port-port-does-not-match-debug-por","errorCode":null,"errorMessage":"CDP WebSocket port {port} does not match debug port {expected_port}","messagePattern":"CDP WebSocket port (.+?) does not match debug port (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/cdp.rs","lineNumber":231,"sourceCode":"    if !matches!(parsed.scheme(), \"ws\" | \"wss\") {\n        bail!(\"CDP WebSocket URL must use ws or wss\");\n    }\n    let host = parsed\n        .host_str()\n        .ok_or_else(|| anyhow::anyhow!(\"CDP WebSocket URL has no host\"))?;\n    let address = host\n        .trim_start_matches('[')\n        .trim_end_matches(']')\n        .parse::<IpAddr>()\n        .with_context(|| \"CDP WebSocket host must be a loopback IP address\")?;\n    if !address.is_loopback() {\n        bail!(\"CDP WebSocket host must be loopback\");\n    }\n    let port = parsed\n        .port()\n        .ok_or_else(|| anyhow::anyhow!(\"CDP WebSocket URL must include an explicit port\"))?;\n    if port != expected_port {\n        bail!(\"CDP WebSocket port {port} does not match debug port {expected_port}\");\n    }\n    Ok(())\n}\n\npub fn pick_page_target(targets: &[CdpTarget]) -> anyhow::Result<CdpTarget> {\n    let mut first_page = None;\n    for target in targets\n        .iter()\n        .filter(|target| is_injectable_page_target(target))\n    {\n        first_page.get_or_insert(target);\n        if is_primary_codex_page_target(target) {\n            return Ok(target.clone());\n        }\n    }\n\n    if let Some(target) = first_page {\n        return Ok(target.clone());","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/cdp.rs#L213-L249","documentation":"Thrown by `validate_cdp_websocket_url` when the URL's explicit port differs from the debug port the caller expects. This catches stale or mismatched endpoints, e.g. after the browser restarted on a different `--remote-debugging-port`.","triggerScenarios":"Calling `validate_cdp_websocket_url(url, expected_port)` where `url.port() != expected_port`, or the URL omits the port (which first raises 'must include an explicit port').","commonSituations":"Cached webSocketDebuggerUrl from a previous browser session on another port, multiple Chrome instances on different ports, or a config file with a stale `debug_port`.","solutions":["Re-fetch the current webSocketDebuggerUrl from `http://127.0.0.1:<expected_port>/json/version` so the port matches","Update the expected_port argument to the port the browser is actually using","Correct any config/env where the port was changed for the browser but not for the library"],"exampleFix":"// before\nvalidate_cdp_websocket_url(\"ws://127.0.0.1:9222/devtools/browser/ABC\", 9223)?;\n// after\nvalidate_cdp_websocket_url(\"ws://127.0.0.1:9222/devtools/browser/ABC\", 9222)?;","handlingStrategy":"validation","validationCode":"fn ws_port_matches(url: &str, expected: u16) -> bool {\n    reqwest::Url::parse(url).map(|u| u.port() == Some(expected)).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-fetch webSocketDebuggerUrl from the live /json/version each session","Keep debug_port in a single source of truth (config) shared with the browser launch flags","After browser restart, re-read the port — it may have changed"],"tags":["cdp","websocket-url","port-mismatch"],"backgroundTag":"invalid-config-value","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}