Streaming API Backoff Strategy

Apr 2, 2015 at 3:17 PM
Hi,
I want to implement a backoff strategy for attempting to reconnect to the Streaming API in accordance with the Twitter API docs at https://dev.twitter.com/streaming/overview/connecting (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 https://tweetinvi.codeplex.com/discussions/554830 but assumed this was no longer correct since at https://tweetinvi.codeplex.com/discussions/573889 @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).
Thanks,
Josh
Coordinator
Apr 12, 2015 at 8: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.

Cheers,
Linvi
Marked as answer by linvi on 4/18/2015 at 3:08 PM
Apr 13, 2015 at 10: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?
Thanks,
Josh
Coordinator
Apr 18, 2015 at 10:08 PM
Hi,

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.

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