Forums

Did something change last night? I can no longer log into Reddit using PRAW 2.0.15

I've been running a script every day that logs into Reddit using PRAW, and it's worked every time until now, which is strange because I didn't change anything. Here's the traceback:

Traceback (most recent call last):
  File "bravery20.py", line 1314, in <module>
    r.login(username=username, password=password)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/__init__.py", line 906, in login
    self.request_json(self.config['login'], data=data)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/decorators.py", line 223, in error_checked_function
    return_value = function(cls, *args, **kwargs)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/__init__.py", line 407, in request_json
    response = self._request(url, params, data)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/__init__.py", line 294, in _request
    timeout=timeout)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/decorators.py", line 64, in __call__
    result = self.function(reddit_session, url, *args, **kwargs)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/decorators.py", line 167, in __call__
    return self.function(*args, **kwargs)
  File "/home/sotb2/.local/lib/python2.7/site-packages/praw/helpers.py", line 137, in _request
    allow_redirects=False, auth=auth)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 399, in post
    return self.request('POST', url, data=data, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 354, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 460, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 246, in send
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='proxy.server', port=3128): Max retries exceeded with url: http://www.reddit.com/api/login/.json (Caused by 
<class 'socket.error'>: [Errno 111] Connection refused)

I'm logging in insecurely because I know PythonAnywhere free accounts don't support SSL, so that's not the problem here. Does it look like the issue is being caused by Reddit or by PythonAnywhere?

Thanks in advance.

It looks as though perhaps the PA proxy server was/is experiencing an outage, but that's a broad guess based on the traceback. Keep trying periodically, hopefully the PA devs will be able to shed more light.

Yup, it was a proxy issue. Someone was hammering an online MMORPG and not getting in, and their script responded by retrying thousands of times a second. I've killed the offending processes.

That fixed it. Thanks!

Also, free accounts do support port 443, not sure why you think they don't.

Now that you mention it, I think it's not that SSL per se is unsupported, but that the particular domain that Reddit uses for it (ssl.reddit.com) is not on the whitelist although the nonsecure domain (www.reddit.com) is.

Just checked this list. Maybe that's not it. There's something that prevents it, though. I'll see if I can figure that out.

I wonder if there's some way of using proxy authentication to prevent these issues where someone takes the proxy down by DoSing it (whether intentionally or not). Still, most standard proxies don't seem to be written with that sort of robustness in mind, so perhaps it wouldn't be so useful. Also, I'm not sure whether it's possible to add auth details to the standard proxy environment variables.

Or perhaps throttle proxy connections to no more than nnn per 5 minutes.

@sotb2 -- there is a bug in one of the more recent HTTP libraries (IIRC it's urllib3, which is used by requests) that makes it send incorrect data when connecting over https via a proxy. So that might be why you thought we don't support SSL -- I see from your stacktrace that you're using requests.

@Cartroo, @a2j. Right, identifying users to the proxy is tricky, so it's hard to do any kind of per-user rate limiting. I think we just need better monitoring...

@giles: Sure, I totally understand it's a tricky problem. Monitoring is always a good thing, although it's always going to be a bit of a pain if someone has to manually investigate outages due to the server becoming overloaded.

If I come across any other bright ideas for how to identify traffic I'll let you know. I was wondering if Linux has a way to use, say, MPLS tags based on the sending user ID or something, but then again that probably won't fly unless you controlled all the underlying switching fabric. Hm. It's an interesting puzzle. (^_^)