API connection reset



I am attempting to grab lots of tweets via search in the API using the Python tweepy library. By lots I mean 20000+ tweets. tweepy builds in functionality that handles waiting on rate limits, and that’s all fine and dandy. However, the underlying library is complaining that Twitter is resetting my connection, which kills the application.

Why would Twitter be resetting my connection? Is there a max number of tweets I am allowed to gather at a time via the search API?


There’s a maximum number of days prior you can search – about a week. I don’t know of a maximum number of tweets. There are several reasons why your connection may drop. You must handle all of them and either reconnect immediately or wait a specified time and reconnect, depending on the cause. Occasionally, Twitter has some unspecified internal error which will break the connection. You probably should begin by inspecting the HTTP status code and, if there is one, the error code and number from Twitter.