0

I am trying to login to a https location and I am facing this error. I am not sure what is causing this issue. Can anyone help me out with this ?

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)

Could anyone help me with this error ?

I also tried including this

import urllib.request
from urllib.request import Request, urlopen
mkl
  • 90,588
  • 15
  • 125
  • 265
Ree
  • 129
  • 3
  • 5
  • 9

1 Answers1

1

In a nutshell, you get:

ConnectionResetError(104, 'Connection reset by peer')

This error does not seem to be SSL related, but network related. Does initiating a simple TCP connection (for example using telnet <host> <port>) work ? Don't you need to go via a proxy ? You can use the proxies parameter to requests.post() (proxies={'https': 'http://yourproxy:port/'})

Guillaume
  • 5,497
  • 3
  • 24
  • 42
  • I tried it. I am getting the following error now: '2017-03-03T14:17:59: %T-ERROR: requests.exceptions.ProxyError: HTTPSConnectionPool(host=’1.1.1.1’, port=443): Max retries exceeded with url: /api/folder/.xml (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 400 Bad Request',))) proxy = {'https': 'http://uname:pwd"@1.1.1.1:443'} resp=requests.post(url,data=data,proxies=proxy,headers=headers,verify=False,cookies=cookies) – Ree Mar 03 '17 at 08:57
  • OSError: Tunnel connection failed: 400 Bad Request – Ree Mar 03 '17 at 09:09
  • Let me guess, your proxy requires NTLM authentication ? Request does not support that for the moment. You might want to use `cntlm`, it is small local proxy that is able to handle NTLM authentication to the real proxy. Also you should use a proper URL for your proxy: `{'https': 'https://uname:pwd@1.1.1.1:443'}` – Guillaume Mar 03 '17 at 09:37
  • Thanks. How can I this cntlm? – Ree Mar 03 '17 at 10:48
  • i am still getting this ConnectionResetRrror. Please help me out with this. Should I include any environment variable ? – Ree Mar 06 '17 at 12:12