python
network_error
ai_generated
true
httpx.ConnectError: [SSL: WRONG_VERSION_NUMBER] 版本号错误 (_ssl.c:1123),连接到'http://api.example.com'时
httpx.ConnectError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123) while connecting to 'http://api.example.com'
ID: python/httpx-connecterror-ssl-wrong-version
80%修复率
88%置信度
0证据数
2024-10-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
尝试在普通HTTP端口上使用HTTPS,反之亦然,导致SSL握手失败。
English
Attempting to use HTTPS on a plain HTTP port, or vice versa, causing SSL handshake failure.
解决方案
-
95% 成功率 Use the correct protocol (http vs https) matching the server configuration
httpx.get('http://api.example.com') # if server uses HTTP, not HTTPS -
90% 成功率 Use the correct port explicitly
httpx.get('https://api.example.com:443') # ensure port 443 for HTTPS
无效尝试
常见但无效的做法:
-
Disabling SSL verification
80% 失败
The issue is not certificate validation but protocol mismatch; disabling SSL does not help.
-
Using a different SSL/TLS version in the client
90% 失败
The server likely does not support SSL on that port at all.