I have been testing a site with a social media login validation. It's quite primitive aside from that I built in the ability to connect through a proxy. This works fine, including the proxy, when I run it from my box or the server the site is on. However, once I enabled https/ssl on my server and used the proxy, it stopped working with this error:
File "myprogram.py", line 274, in login
r = self.s.get(self.url)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 476, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 424, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='socialmediawebsite', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', error(111, 'Connection refused')))
I've read a solid amount and have looked through the code for requests and urllib3, but it seems more and more like I have a fundamental misunderstanding. I've tried HTTPAuth, setting verify to False, and setting environment variables. I have also tried without the proxy, and it works, which has added to my confusion. It seems to me like there might be another piece of technology required to send this https request through the proxy. Or is it just that I have to open up more ports somewhere or something equally simple?
There is one question similar to mine here: Python Requests doesnt work for https proxy
But the accepted answer is factually inaccurate and didn't work for me.
What my code looks like:
proxies = {
'http': 'http://user:[email protected]:3128',
'https': 'http://user:[email protected]:3128',
}
self.s.update(proxies)
self.s.get(self.url)