【python】报错ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1122)
使用requests时,报错ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1122)
完整报错信息如下:
Traceback (most recent call last):
File "D:AcademicPythonPython39libsite-packagesurllib3connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "D:AcademicPythonPython39libsite-packagesurllib3connectionpool.py", line 996, in _prepare_proxy
conn.connect()
File "D:AcademicPythonPython39libsite-packagesurllib3connection.py", line 364, in connect
self.sock = conn = self._connect_tls_proxy(hostname, conn)
File "D:AcademicPythonPython39libsite-packagesurllib3connection.py", line 499, in _connect_tls_proxy
socket = ssl_wrap_socket(
File "D:AcademicPythonPython39libsite-packagesurllib3utilssl_.py", line 453, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "D:AcademicPythonPython39libsite-packagesurllib3utilssl_.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "D:AcademicPythonPython39libssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "D:AcademicPythonPython39libssl.py", line 1040, in _create
self.do_handshake()
File "D:AcademicPythonPython39libssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1122)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:AcademicPythonPython39libsite-packagesrequestsadapters.py", line 489, in send
resp = conn.urlopen(
File "D:AcademicPythonPython39libsite-packagesurllib3connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "D:AcademicPythonPython39libsite-packagesurllib3utilretry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='tsms-drcn.security.dbankcloud.cn', port=443): Max retries exceeded with url: /tsms/v2/attest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1122)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:AcademicWorkplaceDeviceIntegritySafetyDetectHMSAnaweb-curl-py.py", line 17, in <module>
response = requests.post('https://tsms-drcn.security.dbankcloud.cn/tsms/v2/attest', headers=headers, json=json_data)
File "D:AcademicPythonPython39libsite-packagesrequestsapi.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "D:AcademicPythonPython39libsite-packagesrequestsapi.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "D:AcademicPythonPython39libsite-packagesrequestssessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "D:AcademicPythonPython39libsite-packagesrequestssessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "D:AcademicPythonPython39libsite-packagesrequestsadapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='tsms-drcn.security.dbankcloud.cn', port=443): Max retries exceeded with url: /tsms/v2/attest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1122)')))
解决方法:关闭系统网络代理软件(关闭System Proxy)