NanmiCoder/MediaCrawler · error · RuntimeError
CDP connection failed
Error message
CDP connection failed
What it means
Error "CDP connection failed" thrown in NanmiCoder/MediaCrawler.
Source
Thrown at tools/cdp_browser.py:354
utils.logger.info(
f"[CDPBrowserManager] Connecting to existing browser via discovered CDP: {ws_url}"
)
self.browser = await playwright.chromium.connect_over_cdp(
ws_url, timeout=config.BROWSER_LAUNCH_TIMEOUT * 1000
)
else:
# For launched browser, get WebSocket URL first
ws_url = await self._get_browser_websocket_url(self.debug_port)
utils.logger.info(f"[CDPBrowserManager] Connecting to browser via CDP: {ws_url}")
self.browser = await playwright.chromium.connect_over_cdp(ws_url)
if self.browser.is_connected():
utils.logger.info("[CDPBrowserManager] Successfully connected to browser")
utils.logger.info(
f"[CDPBrowserManager] Browser contexts count: {len(self.browser.contexts)}"
)
else:
raise RuntimeError("CDP connection failed")
except Exception as e:
utils.logger.error(f"[CDPBrowserManager] CDP connection failed: {e}")
raise
async def _create_browser_context(
self, playwright_proxy: Optional[Dict] = None, user_agent: Optional[str] = None
) -> BrowserContext:
"""
Create or get browser context
"""
if not self.browser:
raise RuntimeError("Browser not connected")
# Get existing context or create new context
contexts = self.browser.contexts
if contexts:View on GitHub (pinned to d6f7c5bb90)
Solutions
- Ensure the browser process is still alive and did not exit after launch; check logs for a startup crash.
- Verify config.CDP_DEBUG_PORT matches the port the browser is listening on (check chrome://inspect/#remote-debugging or the browser launch output).
- Increase config.BROWSER_LAUNCH_TIMEOUT if the browser is slow to start on your system.
- If connecting to an existing browser on Chrome 136+, accept the confirmation dialog shown in the browser window, then retry.
When it happens
Trigger: Thrown at tools/cdp_browser.py:354 when the library encounters an invalid state.
Common situations: playwright.chromium.connect_over_cdp returned but browser.is_connected() is False, or the connection dropped immediately. Occurs when the WebSocket URL is stale, the browser rejected the connection (confirmation dialog not accepted in Chrome 136+), the browser crashed during launch, or BROWSER_LAUNCH_TIMEOUT is too short. Defensive fix: retry the connection after prompting the user to accept the browser confirmation dialog, and validate the browser process before connecting.
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/6126a7b8a7128db7.
Report an issue: GitHub.