Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: [Streaming API] How to properly reconnect

$
0
0
Oh,

You start asking confidential questions here.
Their are many many ways to implement a reconnect strategy. I have been discussing this over and over.

To make it simple, Tweetinvi is already attempting to reconnect in case of simple failure (very short drop of the connection).
If Tweetinvi cannot handle a drop of connection or any other issue that might occur (believe me there are a lot of scenarios) you can simply listen to the StreamStopped event.

Let me know if the following code helps you enough to solve your problem.
var stream = Stream.CreateSampleStream();
stream.StreamStopped += (sender, args) =>
{
    if (args.Exception != null)
    {
        Thread.Sleep(2000);
        stream.StartStream();
    }
};
stream.StartStream();
Linvi

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>