> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/agent-browser/xiang-ying-dai-ma.md). Agents can also search and read this documentation through its [MCP server](https://developers.oxylabs.io/~gitbook/mcp).

# 响应代码

了解智能体浏览器错误的含义以及如何解决。

错误会出现在不同阶段，因此先确定你的错误发生在哪个阶段：

<table><thead><tr><th width="122.5">阶段</th><th>错误表现</th></tr></thead><tbody><tr><td><a href="#connection-errors">连接</a></td><td>连接被拒绝时返回的 HTTP 状态和消息。</td></tr><tr><td><a href="#session-errors">会话</a></td><td>WebSocket 以代码关闭 <code>3000</code> 以及一个 <code>CDP_*</code> 原因。</td></tr><tr><td><a href="#in-page-errors">页面内</a></td><td>CDP 命令返回错误代码 <code>1337</code>.</td></tr><tr><td><a href="#network-errors">页面流量</a></td><td>响应包含 <code>X-Error-Description</code> 标头。</td></tr></tbody></table>

### 连接错误

浏览器会话开始前，连接即被拒绝。

#### 认证与参数

<table><thead><tr><th width="78">代码</th><th>消息</th><th>原因与解决方案</th></tr></thead><tbody><tr><td><code>400</code></td><td><code>invalid_uri, &#x3C;details></code></td><td>连接 URL 或查询参数格式错误。检查 URL 语法。</td></tr><tr><td><code>400</code></td><td><code>无效的 source: &#x3C;src></code></td><td>不支持 <code>p_src</code> 值。使用 <code>oxybrowser</code> 或移除该参数。</td></tr><tr><td><code>400</code></td><td><code>session_name 必须为 3-36 位字母数字字符或 '-'</code></td><td>无效 <code>session_name</code>。使用以下模式 <code>^[A-Za-z0-9-]{3,36}$</code>.</td></tr><tr><td><code>400</code></td><td><code>keep_alive 需要 session_name</code></td><td><code>keep_alive=true</code> 在未设置以下项的情况下被设置 <code>session_name</code>.</td></tr><tr><td><code>400</code></td><td><code>o_profile_save 需要 o_profile</code></td><td><code>o_profile_save</code> 在未设置配置文件名称的情况下被设置。</td></tr><tr><td><code>400</code></td><td><code>o_profile 只能包含字母、数字...</code></td><td>无效的配置文件名称。使用以下模式 <code>^[a-zA-Z0-9][a-zA-Z0-9_-]{2,35}$</code>.</td></tr><tr><td><code>400</code></td><td><code>record_name 需要 record=true</code></td><td>添加 <code>record=true</code> 到连接 URL 中。</td></tr><tr><td><code>400</code></td><td><code>该账户未启用页面处理程序</code></td><td>移除 <code>page_handler</code> 或联系 Oxylabs 支持。</td></tr><tr><td><code>401</code></td><td><code>缺少认证标头</code></td><td>未收到凭据。请在 URL 中传入： <code>wss://USER:PASS@...</code>.</td></tr><tr><td><code>401</code></td><td><code>无效的认证标头 / 不是有效的 base64</code></td><td>凭据格式错误。请通过 URL 传入，而不要构建自定义标头。</td></tr><tr><td><code>401</code></td><td><code>缺少凭据</code></td><td>凭据不符合 <code>username:password</code> 格式。</td></tr><tr><td><code>401</code></td><td><code>无效凭据</code></td><td>用户名或密码错误，或账户处于非活跃状态。请在控制台中检查。</td></tr><tr><td><code>403</code></td><td><code>source '&#x3C;source>' 未被允许</code></td><td>该 <code>p_src</code> 该值未为你的账户启用。请联系支持。</td></tr></tbody></table>

#### 功能与限制

<table><thead><tr><th width="87">代码</th><th>消息</th><th>原因与解决方案</th></tr></thead><tbody><tr><td><code>403</code></td><td><code>浏览器配置文件功能未启用</code></td><td>你的账户未启用持久化配置文件。请联系支持。</td></tr><tr><td><code>403</code></td><td><code>已达到配置文件上限（最多 &#x3C;N> 个）</code></td><td>在控制台中删除未使用的配置文件，或申请更高上限。</td></tr><tr><td><code>403</code></td><td><code>该账户未启用录制功能</code></td><td>联系支持以启用会话录制。</td></tr><tr><td><code>409</code></td><td><code>该配置文件已被另一个会话使用</code></td><td>另一个会话正在保存到此配置文件。请等待其完成，或在不使用以下项的情况下连接 <code>o_profile_save</code>.</td></tr><tr><td><code>429</code></td><td><code>CDP_SESSION_RATE_LIMIT_REACHED</code></td><td>一秒内启动了超过 10 个新会话。请错开发起连接并使用退避重试。</td></tr><tr><td><code>429</code></td><td><code>CDP_MAX_CONCURRENT_SESSIONS_REACHED</code></td><td>已达到并发会话上限（默认 100）。关闭空闲会话，并确保 <code>browser.close()</code> 始终执行。</td></tr><tr><td><code>429</code></td><td><code>CDP_MAX_PERSISTENT_SESSIONS_REACHED</code></td><td>已达到持久会话上限（默认 5）。重用现有会话名称，或等待空闲会话过期。</td></tr><tr><td><code>429</code></td><td><code>CDP_SESSION_IN_USE</code></td><td>该命名会话已存在活动连接。请先关闭后再重新连接。</td></tr><tr><td><code>503</code></td><td><code>队列超时</code></td><td>容量暂时饱和。请使用指数退避重试。</td></tr></tbody></table>

### 会话错误

WebSocket 连接以代码关闭 `3000` 以及以下原因之一。

<table><thead><tr><th width="248.5">原因</th><th>原因与解决方案</th></tr></thead><tbody><tr><td><code>CDP_NO_BROWSERS_AVAILABLE</code></td><td>当前没有可用浏览器。请使用指数退避重试。</td></tr><tr><td><code>CDP_BROWSER_OVERWORKED_1</code></td><td>浏览器主机已饱和。请重试并使用退避。</td></tr><tr><td><code>CDP_BROWSER_START_FAILED_0</code> <br><code>CDP_BROWSER_START_FAILED_1</code></td><td>浏览器启动失败。请重试并使用退避。</td></tr><tr><td><code>CDP_BROWSER_GONE</code></td><td>浏览器意外停止。请启动新会话。</td></tr><tr><td><code>CDP_SESSION_NOT_FOUND</code></td><td>该命名会话在 10 分钟内未建立连接后已过期。请启动新会话。</td></tr><tr><td><code>CDP_SESSION_IN_USE</code></td><td>另一个客户端已连接到同一命名会话。每个会话仅使用一个连接 <code>session_name</code>.</td></tr><tr><td><code>CDP_BAD_PROXY</code></td><td>无法为请求的位置建立代理。请重试，或使用新的 <code>proxy_resi_ses_id</code> 用于粘性会话。</td></tr><tr><td><code>CDP_BAD_REQUEST</code></td><td>代理和位置参数的组合无效。请检查它们。</td></tr></tbody></table>

### 页面内错误

这些错误会以 CDP 错误返回，代码为 `1337`.

<table><thead><tr><th width="311.5">消息</th><th>原因与解决方案</th></tr></thead><tbody><tr><td><code>无效目标</code></td><td><a href="https://developers.oxylabs.io/products/cn/agent-browser/restricted-targets.md">受限目标</a>。不要重试。</td></tr><tr><td><code>目标过多</code></td><td>该会话拥有超过 <code>1000</code> 个打开的页面。使用完后请关闭这些页面。</td></tr><tr><td><code>当前上下文不允许使用代理</code></td><td><code>Target.createBrowserContext</code> 被调用时使用了 <code>proxyServer</code>。请改为在连接 URL 中设置代理选项。</td></tr></tbody></table>

### 网络错误

当页面请求失败时，请检查 `X-Error-Description` 标头，查看是谁返回了错误：

```javascript
page.on("response", (res) => {
    const error = res.headers()["x-error-description"];
    if (error) console.warn(`Network error on ${res.url()}: ${error}`);
});
```

<table data-header-hidden><thead><tr><th width="154"></th><th></th></tr></thead><tbody><tr><td><strong>标头存在</strong></td><td>Oxylabs 代理网络返回了该错误。请重试请求。</td></tr><tr><td><strong>标头缺失</strong></td><td>网站本身返回了该响应，例如一个 <code>403</code> 或反机器人防护页面。请尝试不同的位置、设备类型或指纹。</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/cn/agent-browser/xiang-ying-dai-ma.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
