# 522 连接超时

helodata 网关返回 `522` 说明代理无法到达（或未完成握手）上游 IP。多为瞬时——`X-Helodata-Error-Code` 区分若干子类型。

## `upstream-timeout` — 后端 IP 未响应

```
HTTP/1.1 522
X-Helodata-Error-Code: upstream-timeout
```

**原因**

* 选中的住宅/移动/ISP IP 在选择后到连接之间下线
* 目标站点慢，超过网关上游超时
* ISP IP 的运营商把连接掐了

**修复**

* 直接重试。换一个出口：
  * 网关产品：去掉 `session` 段获取新 IP
  * ISP：从批次中换另一个 IP

如果 5 分钟内 `upstream-timeout` **比例超过 10%**，不正常——带上若干 `X-Helodata-Request-Id` 开工单。

## `insufficient-pool` — 筛选过窄

```
HTTP/1.1 522
X-Helodata-Error-Code: insufficient-pool
X-Helodata-Insufficient-Pool: true
```

**原因** — 地理 + ASN + 会话组合筛选后在线 IP 不足 10。

**修复** — 按以下顺序放宽：

1. 去 `city`
2. 去 `state`
3. 去 `asn`
4. 换国家

确实需要这么窄的筛选时联系客服——付费套餐可考虑为你预备更大的池。

## 目标 TLS 握手超时

```
HTTP/1.1 502
X-Helodata-Error-Code: upstream-tls-error
```

（严格是 502，但相关。）

**原因** — 到目标的 TLS 中途失败。多为目标侧：证书配置错、OCSP 超时、服务器慢。

**修复** — 见 [SSL / TLS 错误](/helodata-zh/gu-zhang-pai-cha/ssl-errors.md)。

## 程序化处理

```python
RETRYABLE = {"upstream-timeout"}

def on_522(resp, attempt):
    code = resp.headers.get("x-helodata-error-code")
    if code == "insufficient-pool":
        # 放宽筛选——别盲目重试
        raise ConfigError("Loosen geo/ASN filter")
    if code in RETRYABLE and attempt < 5:
        time.sleep(2 ** attempt + random.random())
        return True
    return False
```

## `522` **不是**什么

* 不是目标的 522。Cloudflare 也返回 522——那是**目标站点告诉代理其源站超时**。通过 `X-Helodata-Error-Code` 区分：
  * **有 `X-Helodata-Error-Code`** → helodata 网关错误
  * **无该头，但带 `Server: cloudflare` 与 cf-ray** → 目标的 Cloudflare 在抱怨自己后端，重试帮不大

## 仍未解决

邮件 <support@helodata.com> 并附至少一个 `X-Helodata-Request-Id`。我们会记录上游 IP、目标、超时分解，可告诉你问题在我们还是目标。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helodata.com/helodata-zh/gu-zhang-pai-cha/522.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
