Core Principle: Always check status before using the browser tool.
核心原则:每次使用 browser 工具前,先检查状态。
1. browser(action=status, profile="openclaw")
├─ running=true, cdpReady=true → ✅ OK, proceed / 正常,直接使用
├─ running=false → Try to start / 尝试启动
└─ Start failed → Diagnose and fix / 诊断并修复
Symptoms / 症状:
running=false, cdpReady=falseprofile="user" / 使用 profile="user" 时尤其容易发生Cause / 原因:
Solution / 解决方案:
Use independent profile / 使用独立 profile:
browser(action=start, profile="openclaw") # Port 9223, isolated data dir
Permanent Fix / 永久方案:
Configure defaultProfile: "openclaw":
{
"browser": {
"enabled": true,
"defaultProfile": "openclaw",
"profiles": {
"user": { "cdpPort": 9222, "attachOnly": false },
"openclaw": { "cdpPort": 9223, "attachOnly": false }
}
}
}
Symptoms / 症状:
running=false but port occupied / 端口被占用Diagnosis / 诊断:
# Windows
netstat -ano | findstr "9223"
tasklist | findstr "chrome"
Solution / 解决方案:
# Kill residual process / 杀掉残留进程
taskkill /F /PID <pid>
# Or restart Gateway / 或重启 Gateway
openclaw gateway restart
Symptoms / 症状:
running=true but cdpReady=falseSolution / 解决方案:
# 1. Restart Gateway / 重启 Gateway
openclaw gateway restart
# 2. Wait 5 seconds and recheck / 等待 5 秒后重新检查
browser(action=status, profile="openclaw")
| Profile | Port / 端口 | Data Directory / 数据目录 | Use Case / 适用场景 |
|---|---|---|---|
| --------- | ------------- | -------------------------- | --------------------- |
openclaw | 9223 | ~/.openclaw/browser/openclaw/user-data | Default choice / 默认选择, isolated, no conflict |
user | 9222 | User Chrome data dir / 用户 Chrome 目录 | Need user's logged-in accounts (YouTube etc.) |
⚠️ Before using user profile / 使用 user profile 前:
openclaw instead / 如果用户正在使用浏览器,改用 openclawRun scripts/healthcheck.py for full diagnosis:
python scripts/healthcheck.py --profile openclaw
Output Example / 输出示例:
[OK] Browser enabled: true
[OK] Default profile: openclaw
[OK] CDP port 9223 available
[OK] Browser running: true
[OK] CDP ready: true
[PASS] Browser health check passed
# 1. Check status / 检查状态
status = browser(action=status, profile="openclaw")
# 2. Start if not running / 如果未运行,启动
if not status["running"]:
browser(action=start, profile="openclaw")
# 3. Execute operation / 执行操作
browser(action=snapshot, profile="openclaw")
try:
browser(action=snapshot, profile="openclaw")
except TimeoutError:
# 1. Check status / 检查状态
status = browser(action=status, profile="openclaw")
# 2. Diagnose based on status / 根据状态诊断
if not status["running"]:
browser(action=start, profile="openclaw")
elif not status["cdpReady"]:
exec("openclaw gateway restart")
time.sleep(5)
browser(action=start, profile="openclaw")
Gateway (port 18789)
└── Browser Plugin
├── openclaw profile (port 9223)
│ └── user-data: ~/.openclaw/browser/openclaw/
└── user profile (port 9222)
└── user-data: User Chrome directory
Chrome DevTools Protocol (CDP) for remote debugging:
http://127.0.0.1:9223/jsonws://127.0.0.1:9223/devtools/...Remember: Check first, use later. When timeout occurs, switch profile first.
记住:先检查,后使用。遇到超时,先切换 profile。
共 1 个版本