0

I am making a request using httplib2 and I am getting the following errors

[Errno 104] Connection reset by peer

This is how I have implemented it in my code

import httplib2
timeout = 60
h = httplib2.Http(".cache", timeout=timeout, disable_ssl_certificate_validation=True)
h.request('https://somewebsite.com/some_xml_page.aspx', "GET")

connect fail: (somewebsite.com, 443)
connect fail: (somewebsite.com, 443)
error                                     Traceback (most recent call last)
<ipython-input-7-c8b901c7fdfa> in <module>()
----> 1 h.request('https://somewebsite.com/some_xml_page.aspx', "GET")

/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in request(self, uri, method, body, headers, redirections, connection_type)
   1594                     content = ""
   1595                 else:
-> 1596                     (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
   1597         except Exception, e:
   1598             if self.force_exception_to_status_code:

/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
   1342             auth.request(method, request_uri, headers, body)
   1343 
-> 1344         (response, content) = self._conn_request(conn, request_uri, method, body, headers)
   1345 
   1346         if auth:

/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in _conn_request(self, conn, request_uri, method, body, headers)
   1316                 if i < RETRIES-1:
   1317                     conn.close()
-> 1318                     conn.connect()
   1319                     continue
   1320                 else:

/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in connect(self)
   1049             break
   1050         if not self.sock:
-> 1051           raise socket.error, msg
   1052 
   1053 SCHEME_TO_CONNECTION = {

error: [Errno 104] Connection reset by peer

The server from where I want to fetch the page has TSL 1.1/1.2 but it does not support SSL v3 SSL v2 and TLS 1.0.

My code works when I make requests to

h.request('https://encrypted.google.com', "GET")

https://encrypted.google.com has support for SSL v3.

How can I fetch pages from web servers with TLS 1.1/1.2 protocols and which does not have SSL v3, SSL v2 and TLS 1.0.

Saad
  • 1,856
  • 1
  • 22
  • 28
  • You're obviously missing something - because `timeout` isn't defined in your code. Can you `GET` from this page using some other tool, e.g. `curl`? Also, have you looked at the [requests module](http://docs.python-requests.org/en/latest/)? – Wayne Werner Sep 16 '13 at 22:59
  • yes I know I forgot to paste that but timeout is 60, I will edit my question, I have looked in to 'requests', also changing it to requests will result in a lot of code change. I can get that page using curl command, curl --insecure https://somewebsite.com/some_xml_page.aspx – Saad Sep 16 '13 at 23:22
  • Please, provide more information. Can you show program output with httplib2.debuglevel=4? – sshilovsky Sep 17 '13 at 08:13
  • also, your httplib2 version and python version pls – sshilovsky Sep 17 '13 at 08:14
  • python 2.6.6 httplib2 0.8 the rest error information I have added in the answer – Saad Sep 17 '13 at 20:48

0 Answers0