I have a problem using python requests library in Ubuntu 14.04 when execute the following script:
import requests
import json
payload = {'code':'TG-000000000000000000000000', 'client_secret':'X0000000000000000000000000000000', 'grant_type':'authorization_code', 'client_id':'1111111111111111', 'redirect_uri':'http://127.0.0.1:8000/mercadolibre/process_ml_response/'}
headers = {'content-type': 'application/x-www-form-urlencoded'}
requests.post("https://api.mercadolibre.com:443/oauth/token", data=payload, headers=headers)
I get the following traceback
File "<stdin>", line 1, in <module>
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/adapters.py", line 375, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.mercadolibre.com', port=443): Max retries exceeded with url: /oauth/token (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
If I try the same code in Ubuntu 13.10 works fine
I guest this error is related to the version of openssl (1.0.1f) and requests python library
I try installing pyOpenSSL, ndg-httpsclient and pyasn1 as is suggested in using requests with TLS doesn't give SNI support but doesn't work, also apply the monkey patch before run the script but also fails
Note: when I use pyOpenSSL then the new error that I get is:
request.exceptions.SSLError: [Errno bad handshake](104, 'ECONNRESET')
Thanks for any suggestion
I found a fork of requests that works fine with OpenSSL version of Ubuntu 14.04, https://github.com/joequery/requests-sslv3 only install this fork via pip and requests works well again