Skip to content

BrowserType.connect_over_cdp: 404 Not Found Required resources not found for session #166

@zzxwill

Description

@zzxwill

Run the code below.

from playwright.async_api import async_playwright
import asyncio
from bedrock_agentcore.tools.browser_client import BrowserClient

# Create a browser client
client = BrowserClient(region="us-east-1")

# Start a browser session
client.start()
print(f"Session ID: {client.session_id}")

url, headers = client.generate_ws_headers()


print(url)
print(headers)

async def automate_browser():
    async with async_playwright() as p:
        # Pass the generated headers for authentication, using the correct 'url'
        browser = await p.chromium.connect_over_cdp(url, headers=headers)
        page = (browser.contexts[0] if browser.contexts else await browser.new_context()).new_page()
        await page.goto("https://www.amazon.com")
        # await page.fill("input#twotabsearchtextbox", "laptop")
        # await page.press("input#twotabsearchtextbox", "Enter")
        # await page.wait_for_selector("div.s-main-slot", timeout=10000)
        # await page.screenshot(path="amazon_search.png")
        print("✅ Search complete, screenshot saved.")

await automate_browser()

It hit the issue as below.

rror: BrowserType.connect_over_cdp: WebSocket error: wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation 404 Not Found
Required resources not found for session xxx
Call log:
  - <ws connecting> wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation
  - <ws unexpected response> wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation 404 Not Found
Required resources not found for session xxx
  - <ws error> wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation error WebSocket was closed before the connection was established
  - <ws connect error> wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation WebSocket was closed before the connection was established
  - <ws disconnected> wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation code=1006 reason=

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtoolsRelated to agentcore tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions