Forums

error using reddit praw api

Trying to run my reddit bot and read that that users are able to connect to it as a free user on here. Is there something else thats the problem ?

This is the error i get when it tries to connect and log in:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ssl.reddit.com', port=443): Max retries exceeded with url: / api/login/.json (Caused by <class 'socket.error'>: [Errno 111] Connection refused)

Hmm, that's odd. All of reddit is whitelisted. But normally access from free accounts goes via a proxy, and the requests library uses the proxy (which it picks up the details for from some environment variables).

Are you telling it not to use the proxy in some way? If not, could you give more of the traceback?

Don't think i am telling it not to use any proxy.

heres the full traceback:

Traceback (most recent call last):
File "/home/snawpy/commentREPLYall.py", line 8, in <module>
reddit.login("Care_Corrector", "12poo")
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/init.py", line 1214, in login
self.request_json(self.config['login'], data=data)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/decorators.py", line 161, in wrapped
return_value = function(reddit_session, args, kwargs)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/init.py", line 509, in request_json
response = self._request(url, params, data)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/init.py", line 373, in _request
response = handle_redirect()
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/init.py", line 346, in handle_redirect
timeout=timeout,
kwargs)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/handlers.py", line 135, in wrapped
result = function(cls,
kwargs)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/handlers.py", line 54, in wrapped
return function(cls,
kwargs)
File "/home/snawpy/.local/lib/python2.7/site-packages/praw/handlers.py", line 90, in request
allow_redirects=False)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 486, in send
r = adapter.send(request,
*kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 382, in send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ssl.reddit.com', port=443): Max retries exceeded with url: /api/login/.json (Caused by <class 'socket.error'>: [Errno 111] Connection refused)

There are some Python url libraries that don't work well with SSL. It may be that your reddit library uses one of those.

Oops. Looks like I missed that praw uses requests which is one of the libraries that doesn't have the problem. We'll have to have a more in-depth look.

So it looks like PRAW does not use the proxy settings from the environment for login (and probably other requests that use SSL). It does use them for general access, though.

Ah, so there is no way of using it as a free user on here then ?

Not unless praw gets a fix in so that SSL connections also honour the proxy settings from the environment.

I see, if i upgraded to a hacker account would the problem remain the same ?

No, if you upgrade, the problem should go away -- you'll get unrestricted internet, ie direct access, not via the proxy...