User stream doesnt work but i get no error.


I have used the code below to create a user stream and recieve direct messages. It works in my sample project fine, but when i try to implement it in my existing project, after the stream starts it doesnt trigger the events when it starts or direct message. With brake points in the events it clearly doesnt trigger.

Tweetinvi.Core.Credentials.TwitterCredentials creds = new Tweetinvi.Core.Credentials.TwitterCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);
                Auth.SetUserCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);

                var stream = Tweetinvi.Auth.ExecuteOperationWithCredentials(creds, () =>
                    return Tweetinvi.Stream.CreateUserStream(creds);

                stream.StreamStarted += (sender, args) =>
                    Trace.WriteLine("Stream Started");

                stream.MessageReceived += (s, a) =>
                    Trace.WriteLine("You received the message : {0}", a.Message.Text);

Has anyone had this before? Any ideas? How can i better debug this?



linvi wrote Jan 25, 2016 at 10:32 AM

Hello there,

By default Tweetinvi does not throw any error. In order to be aware of the error please register to the StreamStopped event.

Please visit github for more information (https://github.com/linvi/tweetinvi/wiki/Streams#stop-and-error-handling).
stream.StreamStopped += (sender, args) =>
    var exceptionThatCausedTheStreamToStop = args.Exception;
    var twitterDisconnectMessage = args.DisconnectMessage;