Streaming Live Tweets not working.. Need help .. Twit NPM and node js


#1

Hi guys,

I am using TWit NPM module and node js to use live streams… Initially streams are not working… multiple times i refresh my application and send tweets then application receives the tweets. also, sometimes it receives some times not. Below is my code… Any help highly appreciated.

Requirement : User tweets some company account, our application will stream the tweet and it will send the reply as direct messages to the user. Later user will see that messages and reply to the company account via direct messages.
So i constantly have to stream both tweets and direct messages as well. below is my code.

// streaming Normal tweet
var streamnormalTweets = T.stream(‘statuses/filter’,{track : ‘@pocMantraharsha’});
streamnormalTweets.on(‘tweet’, function (tweet) {

console.log("Received normal tweet");
  ProcessNormaTweet(tweet);

});

streamnormalTweets.on(‘error’, function (tweet) {
console.log(tweet);
});

// streaming direct tweet

var streamDirectTweets = T.stream(‘user’, { stringify_friend_ids: true });
streamDirectTweets.on(‘direct_message’, function (directMsg) {

console.log(“Received Direct tweet”);
processDirectTweet(directMsg);

});

problem : application is not receiving tweets everytime… some time it works sometimes not…