aws / aws/bedrock-agentcore-sdk-python
BrowserType.connect_over_cdp: 404 Not Found Required resources not found for session
- Dominant language
- Python
- Stars
- 761
- Forks
- 147
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 7
Description
Run the code below.
```python
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:
- wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation
- 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
- 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
- wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation WebSocket was closed before the connection was established
- wss://bedrock-agentcore.us-east-1.amazonaws.com/browser-streams/aws.browser.v1/sessions/xxx/automation code=1006 reason=
```
Contributor guide
Assessment
This issue has not been assessed yet.