# httpx.ConnectError: [SSL: WRONG_VERSION_NUMBER] 版本号错误 (_ssl.c:1123)，连接到'http://api.example.com'时

- **ID:** `python/httpx-connecterror-ssl-wrong-version`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试在普通HTTP端口上使用HTTPS，反之亦然，导致SSL握手失败。

## 版本兼容性

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

## 解决方案

1. **Use the correct protocol (http vs https) matching the server configuration** (95% 成功率)
   ```
   httpx.get('http://api.example.com')  # if server uses HTTP, not HTTPS
   ```
2. **Use the correct port explicitly** (90% 成功率)
   ```
   httpx.get('https://api.example.com:443')  # ensure port 443 for HTTPS
   ```

## 无效尝试

- **Disabling SSL verification** — The issue is not certificate validation but protocol mismatch; disabling SSL does not help. (80% 失败率)
- **Using a different SSL/TLS version in the client** — The server likely does not support SSL on that port at all. (90% 失败率)
