Jun 2, 2014 at 9:40 AM
Edited Jun 2, 2014 at 9:41 AM
I am trying to create a new instance of filtered stream every time a new track is to be added to the stream.
// code that is called every time new track is added to DB and it initiate new filtered stream instance against
static void InitStream()
IFilteredStream filteredStream = Tweetinvi.Stream.CreateFilteredStream();
TwitterCredentials.ApplicationCredentials, () =>
// _Twitters dictionary contains list of existing @mentions users as [twitter-screen-name, twitter-oauth-credentials]
foreach (var t in _Twitters)
filteredStream.AddTrack("@" + t.Key);
filteredStream.MatchingTweetReceived += (sender, args) =>
Console.WriteeLine("@" + args.Tweet.Creator.ScreenName + ": " + args.Tweet.Text);
if (ExceptionHandler.GetLastException() != null)
Console.WriteeLine("Error: " + ExceptionHandler.GetLastException().TwitterExceptionInfos.First().Message + Environment.NewLine);
Main() method calling InitStream() first time, it runs perfectly fine and stream starts listening to @mentions tracks successfully.
static void main (args)
TwitterCredentials.ApplicationCredentials = TwitterCredentials.CreateCredentials(
AddNewTrack() method calling InitStream() next time, when new @mention user is added to system. It just causes error in InitStream() as "Connection limit exceeded for User"
static void AddNewTrack ()
As a history:
- How can I make sure that there is no previous stream running before doing InitStream() ?
- Is there a way to KILL ALL existing streams ?
_I actually intended to add tracks (@mentions) into a running filtered stream and used following code as suggested [
But unfortunately, after adding a new track, stream was always either shutdown with unknown error OR stopped listening to tweets at all.
So leaving that problem unsolved, I am tried the above mentioned way as alternate and still having issue in that._
Please help me to fix the issue of adding new tracks to a running steam, its badly needed .