{"record":{"id":"05715c940ade6ca8","repo":"NanmiCoder/MediaCrawler","slug":"websocketdebuggerurl-not-found","errorCode":null,"errorMessage":"webSocketDebuggerUrl not found","messagePattern":"webSocketDebuggerUrl not found","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/cdp_browser.py","lineNumber":306,"sourceCode":"    async def _get_browser_websocket_url(self, debug_port: int) -> str:\n        \"\"\"\n        Get browser WebSocket connection URL\n        \"\"\"\n        try:\n            async with httpx.AsyncClient() as client:\n                response = await client.get(\n                    f\"http://localhost:{debug_port}/json/version\", timeout=10\n                )\n                if response.status_code == 200:\n                    data = response.json()\n                    ws_url = data.get(\"webSocketDebuggerUrl\")\n                    if ws_url:\n                        utils.logger.info(\n                            f\"[CDPBrowserManager] Got browser WebSocket URL: {ws_url}\"\n                        )\n                        return ws_url\n                    else:\n                        raise RuntimeError(\"webSocketDebuggerUrl not found\")\n                else:\n                    raise RuntimeError(f\"HTTP {response.status_code}: {response.text}\")\n        except Exception as e:\n            utils.logger.error(f\"[CDPBrowserManager] Failed to get WebSocket URL: {e}\")\n            raise\n\n    async def _connect_via_cdp(self, playwright: Playwright):\n        \"\"\"\n        Connect to browser via CDP\n        \"\"\"\n        try:\n            if config.CDP_CONNECT_EXISTING:\n                # Existing browser remote debugging in Chrome 136+ does not expose\n                # /json/version. Connect directly and wait for user confirmation.\n                ws_url = f\"ws://localhost:{self.debug_port}/devtools/browser\"\n                utils.logger.info(f\"[CDPBrowserManager] Connecting to existing browser via CDP: {ws_url}\")\n                utils.logger.info(\n                    \"[CDPBrowserManager] Please check your browser for a confirmation dialog and accept it\"","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/tools/cdp_browser.py#L288-L324","documentation":"Error \"webSocketDebuggerUrl not found\" thrown in NanmiCoder/MediaCrawler.","triggerScenarios":"Thrown at tools/cdp_browser.py:306 when the library encounters an invalid state.","commonSituations":"The HTTP request to http://localhost:<debug_port>/json/version returned 200 but the JSON body lacks 'webSocketDebuggerUrl'. Happens with Chrome 136+ where remote debugging no longer exposes /json/version, when the browser was started without --remote-debugging-port, or when a non-browser service occupies the port. Defensive fix: verify the debug port serves a real Chrome DevTools endpoint before parsing, and fall back to the direct ws://localhost:<port>/devtools/browser connection.","solutions":["Restart the browser with remote debugging enabled: launch Chrome/Edge with --remote-debugging-port=<CDP_DEBUG_PORT> and no other Chrome instance using the same profile.","Verify the debug endpoint manually: curl http://localhost:<CDP_DEBUG_PORT>/json/version and confirm the JSON contains webSocketDebuggerUrl.","Check that CDP_DEBUG_PORT in config matches the port the browser was actually started with, and that no firewall or other process is interfering with localhost access.","If using Chrome 136+, the /json/version endpoint may not expose webSocketDebuggerUrl for existing instances; connect directly to ws://localhost:<port>/devtools/browser or relaunch the browser via the launcher."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}