SSl Error

Showing 1-7 of 7 messages
SSl Error Vineeth 12/24/11 9:18 PM
I am using the following program for getting the streaming API of tweepy. But suddenly my program gets terminated due to SSL Error. The ssl error is very random some times my streaming api runs for 2 or 3 days some times it stops within few hours. Can some one help me with this?

The Streaming API I use is from the following link

The error I get is as below.

Traceback (most recent call last):
  File "", line 117, in <module>
    streaming_api.sample(count=None, async=None)
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.8-py2.7.egg/tweepy/", line 195, in sample
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.8-py2.7.egg/tweepy/", line 161, in _start
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.8-py2.7.egg/tweepy/", line 118, in _run
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.8-py2.7.egg/tweepy/", line 146, in _read_loop
    c =
  File "/usr/lib/python2.7/", line 541, in read
    return self._read_chunked(amt)
  File "/usr/lib/python2.7/", line 574, in _read_chunked
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib/python2.7/", line 476, in readline
    data = self._sock.recv(self._rbufsize)
  File "/usr/lib/python2.7/", line 232, in recv
  File "/usr/lib/python2.7/", line 151, in read
ssl.SSLError: The read operation timed out

Re: SSl Error joshthecoder 12/29/11 1:09 PM
Twitter requires you use SSL for streaming API. You are lucky it even works sometimes.
Re: SSl Error joshthecoder 12/29/11 1:12 PM
Sorry ignore that previous response, I didn't read your message close enough.
You are using SSL just fine it looks like, but it's running into an error when reading.
This could be from the other end closing the connection or some network error.
We may need to handle this better in Tweepy. You may just make your application
reconnect automatically and handle these errors gracefully.

On Saturday, December 24, 2011 at 11:18 PM, vineeth rakesh wrote:

Re: SSl Error 8/3/12 11:03 AM
What is the best way to catch this error so that the program and reconnect automatically?  I have added try/except statements around but the exception doesn't appear to be be raised to this level.  Any advice would be appreciated.
Re: SSl Error Paul Lam 10/22/12 1:16 PM
anyone solved this?
Re: SSl Error David Vasconcelos 10/24/12 12:18 PM
I'm using Tweepy 1.11 and I noticed this issue when I called userstream with async=True.

(I couldn't tell from the original post if filter() was being called with this flag.)

In any case, I worked around my problem by defining my own thread that calls userstream(async=False).

It looks something like this:

class UserStreamThread(Thread):
    # ... Your __init__()

    def run(self):
        while True:
            # Call tweepy's userstream method with async=False to prevent
            # creation of another thread.
                # Normal exit: end the thread
                # Abnormal exit: Reconnect
                log.exception("userstream terminated unexpectedly")

            nsecs = random.randint(57, 63)
            log.error("reconnect in {0} seconds.".format(nsecs))

Hope this helps,

- David
Re: SSl Error Dmitry Kharlamov 10/26/12 4:21 AM
I just pass async=False to the Stream() and it doesn't help. Do I have to define the thread myself?
The weird thing, is that Stream works for me most of the time. But sometimes, (quite often lately) I'm getting these SSL errors.