# requests.exceptions.ConnectionError: HTTPConnectionPool(host='proxy.example.com', port=8080): 超过最大重试次数 (由ProxyError('无法连接到代理。', ConnectionResetError(104, '连接被对端重置'))引起)

- **ID:** `python/requests-connectionerror-proxy-connection-reset`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

代理服务器突然关闭连接，可能是由于超时或过载。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Use a different proxy server** (85% 成功率)
   ```
   proxies = {'http': 'http://new-proxy.example.com:8080'}
requests.get('http://target.com', proxies=proxies)
   ```
2. **Add a delay between connection attempts to avoid overwhelming the proxy** (75% 成功率)
   ```
   import time
for _ in range(3):
    try:
        response = requests.get('http://target.com', proxies=proxies)
        break
    except requests.exceptions.ConnectionError:
        time.sleep(2)
   ```

## 无效尝试

- **Retrying immediately with the same proxy** — The proxy may still be overloaded or resetting connections. (80% 失败率)
- **Increasing the number of retries** — Retries may succeed temporarily but the underlying proxy issue persists. (70% 失败率)
