Streaming API Backoff Strategy

Apr 2, 2015 at 4:17 PM
I want to implement a backoff strategy for attempting to reconnect to the Streaming API in accordance with the Twitter API docs at (Reconnecting section).

What is currently the best way to go about doing this through TweetInvi?
I see there has been some previous discussion around this at but assumed this was no longer correct since at @linvi says the ExceptionHandler should be set to not swallow web exceptions due to it being thread specific (and streams get listened to in separate threads).
Apr 12, 2015 at 9:36 PM
Hi Josh,

I am constantly trying to improve the Reconnect part of the Streams.
Though I leave it to the developers to implement their reconnect strategy on their own. Personally I do not have increase delays in my reconnect strategies and I never encountered any issue by doing so.

I cannot implement the reconnect strategy for the developers as each of them might want to handle these differently.
But the idea is simply that when the Stopped event is received you can listen to the event and react based on the information you received.

As per the ExceptionHandler. Tweetinvi is no longer supporting it for Streams at the moment because as I said, you could expect the ExceptionHandler to be the one from the main thread (from which the stream has been created or the one from the actual running thread).

Please let me know if you need more information.

Marked as answer by linvi on 4/18/2015 at 3:08 PM
Apr 13, 2015 at 11:50 AM
Hi Linvi,
Thanks for the information.
Knowing that you haven't had the need to implement a backoff strategy means I can probably put it on the back burner for a bit :)

Out of interest, what's the largest number of streams that you've been able to run simultaneously without problems & do you ever find Twitter disconnecting a stream without supplying a disconnect message?
Also, has TweetInvi ever been used with the Site Stream?
Apr 18, 2015 at 11:08 PM

Concerning the number of streams that you can run simultaneously, I had been able to run 2 public streams at the same time, but no more.
In the documentation it says that you should not be able to run 2 public stream at the same time.

In the meantime you can run as many UserStream as you want. Obviously this will require credentials for each of the User you want to follow.

Marked as answer by linvi on 4/18/2015 at 3:08 PM