Stream get disconnected somehow without any errors
I have a node.js app which is listening while the application is alive. Somehow it seems like the stream get disconnected but I can't seem to find any reason, neither an error. Any suggestion about how to manage this?
twit.stream('user', {track:'pcolazurdo'}, function(stream) { stream.on('data', function(data) { console.log(util.inspect(data)); if (typeof data.id_str !== 'undefined') insert_doc(data); }); stream.on('error', function(data) { console.log(util.inspect(data)); }); });
(No error is logged either)
Thanks in advance, Pablo
You probably can't authorize because your system clock is out of sync.
happens to me for a while now, never raised an issue. +1
I couldn't find the error (clock out of sync doesn't seem to be the problem) ... I've applied an awful hack which is to restart the server whenever I don't see any update in x mins.
See if you can get on('done') event output, there should be response somewhere in it with status code.
Hello,
i'm not shure if this is related to this issue, but i experience 'stalled' connection when streaming API (filter/statuses endpoint). When having a look at the sources i could not find the code, that is handling the keep-alive packets delivered by the API (see dev.twitter.com 'Stalls'). If i got it right, in parser.js line 36 json = this.buffer.slice(0, index); returns an empty array if this.buffer.match(/^\r\n$/). Thus, nothing will happen on receiving the keep-alive. My workaround for now is, to patch parser.js and emit a 'keep-alive' event and monitor the heartbeat in my client code. I didn't have the chance to perform a long-running test, but it seems to work. My workaround code:
var heartbeat_expr = new RegExp(util.format('^%s$', Parser.END), 'g');
if (this.buffer.match(heartbeat_expr)) {
this.emit('keep-alive');
}
Since i'm not entirely sure, if i am right with my analysis, it would be nice, to check, if and how the keep-alive newlines are handled.
i have same issue.
My Code is :
var Twitter = require('twitter');
var client = new Twitter({
consumer_key: 'xxx',
consumer_secret: xxx',
access_token_key: 'xxx',
access_token_secret: 'xxx',
});
// Stream
client.stream('statuses/filter', {track: 'america'}, function(stream) {
stream.on('data', function(tweet) {
console.log(tweet.text);
console.log("Get Success !!!");
});
stream.on('error', function(error) {
console.log("Error in stream");
console.log(""+error);
});
});
it will not get error connection close directly on linux machine. and my credential is correct. i was tested same credential for post data on twitter.
+1
Doing some playing around and I think I'm seeing this issue on GET statuses/sample:
It will always run for about ~30s before exiting. I see nothing in the twitter docs mentioning a 30s limit so I'm guessing it's this issue? Related to #92 ?
+1
I am able to capture the 'end' event.
client.stream('statuses/filter', {track: 'javascript'}, function(stream) {
stream.on('data', function(tweet) {
console.log(tweet.text);
});
stream.on('error', function(error) {
throw error;
});
stream.on('end', function(reason) {
console.log('end');
console.log(reason);
});
});
When would this be emitted?
I get the 'end' when I try to run this from the current master. When I run this, it quits immediately. Then I went back to [0b69ff0] ie.(v1.2.5), This runs without issues.
Any update / resolution on this? @aswins @desmondmorris
+1
+1
+1
+1
+1
This library is no longer maintained.
twitter-lite has streaming support as well, and is actively maintained.