NanmiCoder/MediaCrawler · error · RuntimeError

HTTP {response.status_code}: {response.text}

Error message

HTTP {response.status_code}: {response.text}

What it means

Error "HTTP {response.status_code}: {response.text}" thrown in NanmiCoder/MediaCrawler.

Source

Thrown at tools/cdp_browser.py:308

        Get browser WebSocket connection URL
        """
        try:
            async with httpx.AsyncClient() as client:
                response = await client.get(
                    f"http://localhost:{debug_port}/json/version", timeout=10
                )
                if response.status_code == 200:
                    data = response.json()
                    ws_url = data.get("webSocketDebuggerUrl")
                    if ws_url:
                        utils.logger.info(
                            f"[CDPBrowserManager] Got browser WebSocket URL: {ws_url}"
                        )
                        return ws_url
                    else:
                        raise RuntimeError("webSocketDebuggerUrl not found")
                else:
                    raise RuntimeError(f"HTTP {response.status_code}: {response.text}")
        except Exception as e:
            utils.logger.error(f"[CDPBrowserManager] Failed to get WebSocket URL: {e}")
            raise

    async def _connect_via_cdp(self, playwright: Playwright):
        """
        Connect to browser via CDP
        """
        try:
            if config.CDP_CONNECT_EXISTING:
                # Existing browser remote debugging in Chrome 136+ does not expose
                # /json/version. Connect directly and wait for user confirmation.
                ws_url = f"ws://localhost:{self.debug_port}/devtools/browser"
                utils.logger.info(f"[CDPBrowserManager] Connecting to existing browser via CDP: {ws_url}")
                utils.logger.info(
                    "[CDPBrowserManager] Please check your browser for a confirmation dialog and accept it"
                )
                try:

View on GitHub (pinned to d6f7c5bb90)

Solutions

  1. Check the HTTP status code in the message: a non-200 from /json/version means the browser debug endpoint is unreachable or rejected the request.
  2. Confirm the browser is running and was started with --remote-debugging-port matching config.CDP_DEBUG_PORT.
  3. Test the endpoint directly: curl http://localhost:<CDP_DEBUG_PORT>/json/version to see the raw response.
  4. Ensure no proxy or security software is intercepting localhost HTTP requests, and retry after restarting the browser.

When it happens

Trigger: Thrown at tools/cdp_browser.py:308 when the library encounters an invalid state.

Common situations: The GET to /json/version on the browser debug port returned a non-200 status. Typical causes: browser not running, remote debugging not enabled (--remote-debugging-port missing), wrong CDP_DEBUG_PORT, or a firewall/proxy intercepting localhost. Defensive fix: check that the browser process is alive and the port is listening before requesting, and include the port and status in the error so users can verify with curl http://localhost:<port>/json/version.


AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15). Data as JSON: /api/errors/6007cba835e6ebd7. Report an issue: GitHub.