gpt4 book ai didi

python - SSL错误 : ("bad handshake: SysCallError(54, ' ECONNRESET')", )

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:01 24 4
gpt4 key购买 nike

我正在尝试使用请求库向服务器发出发布请求。我正在使用以下堆栈:

appdirs==1.4.3
asn1crypto==0.22.0
boto==2.46.1
certifi==2017.4.17
cffi==1.10.0
cryptography==1.8.1
enum34==1.1.6
idna==2.5
inflection==0.3.1
ipaddress==1.0.18
ndg-httpsclient==0.4.2
packaging==16.8
pyasn1==0.2.3
pycparser==2.17
pyOpenSSL==17.0.0
pyparsing==2.2.0
qds-sdk==1.9.6
requests==2.13.0
six==1.10.0
urllib3==1.21.1

但是请求总是失败并出现以下错误:

Traceback (most recent call last):
File "/usr/local/bin/qds.py", line 625, in <module>
sys.exit(main())
File "/usr/local/bin/qds.py", line 575, in main
return cmdmain(a0, args)
File "/usr/local/bin/qds.py", line 203, in cmdmain
return globals()[action + "action"](cmdclass, args)
File "/usr/local/bin/qds.py", line 138, in runaction
cmd = cmdclass.run(**args)
File "/usr/local/lib/python2.7/site-packages/qds_sdk/commands.py", line 96, in run
cmd = cls.create(**kwargs)
File "/usr/local/lib/python2.7/site-packages/qds_sdk/commands.py", line 77, in create
return cls(conn.post(cls.rest_entity_path, data=kwargs))
File "/usr/local/lib/python2.7/site-packages/qds_sdk/connection.py", line 59, in post
return self._api_call("POST", path, data)
File "/usr/local/lib/python2.7/site-packages/qds_sdk/connection.py", line 98, in _api_call
return self._api_call_raw(req_type, path, data=data, params=params).json()
File "/usr/local/lib/python2.7/site-packages/qds_sdk/connection.py", line 86, in _api_call_raw
r = x.post(url, timeout=300, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 535, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
SSLError: ("bad handshake: SysCallError(54, 'ECONNRESET')",)

我用open 0.9.8连接服务器报如下错误:

> openssl s_client -connect <ip>:443
CONNECTED(00000003)
write:errno=54

但是在 openssl 上使用更高版本连接成功,我认为 python 在某种程度上使用了较低版本,但是当我检查 ssl 时,它显示了较高版本:

> python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.0.2k 26 Jan 2017

不确定这里发生了什么。我不确定如何设置格式,对此深表歉意。

最佳答案

我能够找到解决此问题的方法,我只是在创建 PoolManager 时将 ssl 协议(protocol)类型从“ssl.PROTOCOL_TLSv1”更改为“ssl.PROTOCOL_TLSv1_2”,如下所示,这解决了上述问题:

self.poolmanager = PoolManager(num_pools=connections,
maxsize=maxsize,
block=block,
ssl_version=ssl.PROTOCOL_TLSv1_2)

但上面会给出 InsecureRequests 警告,您可以使用以下命令抑制相同的警告:

from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

希望对您有所帮助。

关于python - SSL错误 : ("bad handshake: SysCallError(54, ' ECONNRESET')", ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43846689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com