Tweepy Openssl.ssl.wantreaderror
Solution 1:
This looks more like a temporary connection timeout which is not handled by Tweepy
, so you should just write a wrapper around the same and catch the exception and restart it. I don't think the exception can be avoided as such because you connect to an external site and sometimes it could timeout
You should look at this http://docs.tweepy.org/en/v3.5.0/streaming_how_to.html#handling-errors for the error handling part and see if on_error
gets called in your case when connection timeout happens
classMyStreamListener(tweepy.StreamListener):
defon_error(self, status_code):
if status_code == 420:
#returning False in on_data disconnects the streamreturnFalse
If this doesn't help then use the wrapper approach
Solution 2:
According to Twitter Developer documentation : rate limiting this is expected to connection reset/failure when you cross your usage limit.
Requests / 15-min window (user auth) = 900
Requests / 15-min window (app auth) = 1500
Also it clearly states as below.
If the initial reconnect attempt is unsuccessful, your client should continue attempting to reconnect using an exponential back-off pattern until it successfully reconnects.
(Update)
Regardless of how your client gets disconnected, you should configure your app to reconnect immediately. If your first reconnection attempt is unsuccessful, we recommend that your app implement an exponential back-off pattern in subsequent reconnection attempts (e.g. wait 1 second, then 2 seconds, then 4, 8, 16, etc), with some reasonable upper limit. If this upper limit is reached, you should configure your client to notify your team so that you can investigate further.
The standard (free) Twitter APIs i.e Tweepy API consist of a REST API and a Streaming API. The Streaming API provides low-latency access to Tweets. Ads API has other limits when white listed.
REST API Limit
Clients may access a theoretical maximum of 3,200 statuses via the page and count parameters for the user_timeline REST API methods. Other timeline methods have a theoretical maximum of 800 statuses. Requests for more than the limit will result in a reply with a status code of 200 and an empty result in the format requested. Twitter still maintains a database of all the Tweets sent by a user. However, to ensure performance, this limit is in place on the API calls.
Could be simple reason that users should not spam that this thing is enforced.
Solution :
You may catch exception
and re-establish connection to Twitter and continue reading tweets.
There is no alternative than getting better usage allowance from Twitter as of now unfortunately.
Post a Comment for "Tweepy Openssl.ssl.wantreaderror"