2017-03-03 320 views
0

我想登錄到一個https位置,我面臨這個錯誤。我不確定是什麼導致了這個問題。任何人都可以幫我解決這個問題嗎?python連接錯誤ssl

2017-03-03T12:00:23: %T-ERROR: Caught exception during execution: 
2017-03-03T12:00:23: %T-ERROR: Traceback (most recent call last): 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen 
2017-03-03T12:00:23: %T-ERROR:  chunked=chunked) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request 
2017-03-03T12:00:23: %T-ERROR:  self._validate_conn(conn) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn 
2017-03-03T12:00:23: %T-ERROR:  conn.connect() 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 326, in connect 
2017-03-03T12:00:23: %T-ERROR:  ssl_context=context) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/util/ssl_.py", line 336, in ssl_wrap_socket 
2017-03-03T12:00:23: %T-ERROR:  return context.wrap_socket(sock) 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 364, in wrap_socket 
2017-03-03T12:00:23: %T-ERROR:  _context=self) 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 578, in __init__ 
2017-03-03T12:00:23: %T-ERROR:  self.do_handshake() 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 805, in do_handshake 
2017-03-03T12:00:23: %T-ERROR:  self._sslobj.do_handshake() 
2017-03-03T12:00:23: %T-ERROR: ConnectionResetError: [Errno 104] Connection reset by peer 
2017-03-03T12:00:23: %T-ERROR: 
2017-03-03T12:00:23: %T-ERROR: During handling of the above exception, another exception occurred: 
2017-03-03T12:00:23: %T-ERROR: 
2017-03-03T12:00:23: %T-ERROR: Traceback (most recent call last): 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/adapters.py", line 423, in send 
2017-03-03T12:00:23: %T-ERROR:  timeout=timeout 
2017-03-03T12:00:23: %T-ERROR:File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen 
2017-03-03T12:00:23: %T-ERROR: stacktrace=sys.exc_info()[2]) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 347, in increment 
2017-03-03T12:00:23: %T-ERROR:  raise six.reraise(type(error), error, _stacktrace) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 685, in reraise 
2017-03-03T12:00:23: %T-ERROR:  raise value.with_traceback(tb) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen 
2017-03-03T12:00:23: %T-ERROR:  chunked=chunked) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request 
2017-03-03T12:00:23: %T-ERROR:  self._validate_conn(conn) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn 
2017-03-03T12:00:23: %T-ERROR:  conn.connect() 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 326, in connect 
2017-03-03T12:00:23: %T-ERROR:  ssl_context=context) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/packages/urllib3/util/ssl_.py", line 336, in ssl_wrap_socket 
2017-03-03T12:00:23: %T-ERROR:  return context.wrap_socket(sock) 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 364, in wrap_socket 
2017-03-03T12:00:23: %T-ERROR:  _context=self) 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 578, in __init__ 
2017-03-03T12:00:23: %T-ERROR:  self.do_handshake() 
2017-03-03T12:00:23: %T-ERROR: File "/auto/pysw/cel55/python/3.4.1/lib/python3.4/ssl.py", line 805, in do_handshake 
2017-03-03T12:00:23: %T-ERROR:  self._sslobj.do_handshake() 
2017-03-03T12:00:23: %T-ERROR: requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) 
2017-03-03T12:00:23: %T-ERROR: 
2017-03-03T12:00:23: %T-ERROR: During handling of the above exception, another exception occurred: 
2017-03-03T12:00:23: %T-ERROR: 
2017-03-03T12:00:23: %T-ERROR: Traceback (most recent call last): 
2017-03-03T12:00:23: %T-ERROR: File "usr/scripts/new_script.py", line 57, in setup 
2017-03-03T12:00:23: %T-ERROR:  t.cfgmpbgp(rrnode = '201', local = '100') 
2017-03-03T12:00:23: %T-ERROR: File "usr/scripts/new.py", line 28, in wrapper 
2017-03-03T12:00:23: %T-ERROR:  resp=requests.post(url,data=data,headers=headers,verify=False,cookies=cookies) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/api.py", line 110, in post 
2017-03-03T12:00:23: %T-ERROR:  return request('post', url, data=data, json=json, **kwargs) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/api.py", line 56, in request 
2017-03-03T12:00:23: %T-ERROR:  return session.request(method=method, url=url, **kwargs) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/sessions.py", line 488, in request 
2017-03-03T12:00:23: %T-ERROR:  resp = self.send(prep, **send_kwargs) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/sessions.py", line 609, in send 
2017-03-03T12:00:23: %T-ERROR:  r = adapter.send(request, **kwargs) 
2017-03-03T12:00:23: %T-ERROR: File "usr/lib/python3.4/site-packages/requests/adapters.py", line 473, in send 
2017-03-03T12:00:23: %T-ERROR:  raise ConnectionError(err, request=request) 

任何人都可以幫我解決這個錯誤嗎?

我也試過,包括這個

import urllib.request 
from urllib.request import Request, urlopen 

回答

1

簡而言之,您可以:

ConnectionResetError(104, 'Connection reset by peer') 

這個錯誤似乎並不符合SSL相關,但與網絡相關的。 是否啓動簡單的TCP連接(例如使用telnet <host> <port>)? 你不需要通過代理?您可以使用proxies參數requests.post()(proxies={'https': 'http://yourproxy:port/'}

+0

我試過了。我現在得到以下錯誤: – Ree

+0

我試過了。現在我收到以下錯誤:'2017-03-03T14:17:59:%T-ERROR:requests.exceptions.ProxyError:HTTPSConnectionPool(host ='1.1.1.1',port = 443):超過URL的最大重試次數:/api/folder/.xml(由ProxyError引起('無法連接到代理服務器',OSError('Tunnel connection failed:400 Bad Request',)))proxy = {'https':'http:// uname: – Ree

+0

OSError:隧道連接失敗:400錯誤的請求 – Ree