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

Commented Unassigned: NullReference exceptions [2144]

$
0
0
Hiya,

I am using TweetInvi as part of a service that monitors a Twitter account, and replies according to various events (mentions, new followers). I've had a few cases where the entire sevice dies due to TweetInvi throwing a NullReference exception at random. Below are two example errors that I've seen in the event viewer:

```
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.UserStream.StartStream()


Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.FilteredStream.StartStreamMatchingAnyCondition()
```

These exceptions get thrown "mid-flight", with the service having already been running for a few hours/days. The API is initialised like so:

```
TwitterCredentials.Credentials =
TwitterCredentials.CreateCredentials(configuration.Authentication.AccessToken,
configuration.Authentication.AccessTokenSecret, configuration.Authentication.ConsumerKey,
configuration.Authentication.ConsumerSecret);

currentUser = User.GetLoggedUser();
userStream = Stream.CreateUserStream();
userStream.TweetCreatedByAnyone += UserStreamOnTweetCreatedByAnyone;
userStream.MessageReceived += UserStreamOnMessageReceived;
userStream.DisconnectMessageReceived += UserStreamOnDisconnectMessageReceived;
userStream.UnmanagedEventReceived += UserStreamOnUnmanagedEventReceived;
userStream.FollowedByUser += UserStreamOnFollowedByUser;
ThreadPool.QueueUserWorkItem(state => userStream.StartStream());

filteredStream = Stream.CreateFilteredStream();

foreach (TrackElement track in configuration.Tracking)
filteredStream.AddTrack(track.Track);

filteredStream.MatchingTweetReceived += FilteredStreamOnMatchingTweetReceived;
ThreadPool.QueueUserWorkItem(state => filteredStream.StartStreamMatchingAnyCondition());
```

I am using version 0.9.0.0 of the TweetInvi library.

Is this a known issue, or am I doing something wrong?
Comments: ** Comment from web user: albiro **

Hi Linvi,

I've been running 0.9.1. for a month now, and I no longer get unhandler exceptions thrown within the Event Viewer, but I am still having the issue whereby, with no warning, I stop getting messages from the IUserStream.TweetCreatedByAnyone event.

I put in a "hack" into my service to restart the service every 24 hours, thus initiating a new session with Twitter, but some days it barely lasts 8 or 9 hours before messages are no longer received. The only way I know that I am no longer receiving messages is by looking at the twitter notification page, and seeing that my service logs haven't reacted to it.

I listen to the IUserStream's DisconnectMessageReceived and UnmanagedEventReceived events, in case something is happening behind the scenes I'm not aware of, but Tweetinvi has never triggered those events in any of my scenarios where messages are no longer received.

Any ideas?


Regards,
Alvaro


Viewing all articles
Browse latest Browse all 4126

Trending Articles



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