mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
back off twitter retry to twitter recommended 60s
This commit is contained in:
parent
741d3db06b
commit
5d7d7e9d24
@ -193,7 +193,6 @@ module.exports = function(RED) {
|
|||||||
try {
|
try {
|
||||||
var thing = 'statuses/filter';
|
var thing = 'statuses/filter';
|
||||||
var tags = node.tags;
|
var tags = node.tags;
|
||||||
var tout;
|
|
||||||
var st = { track: [tags] };
|
var st = { track: [tags] };
|
||||||
|
|
||||||
var setupStream = function() {
|
var setupStream = function() {
|
||||||
@ -219,20 +218,22 @@ module.exports = function(RED) {
|
|||||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
//node.warn(RED._("twitter.errors.ratelimit"));
|
||||||
});
|
});
|
||||||
stream.on('error', function(tweet,rc) {
|
stream.on('error', function(tweet,rc) {
|
||||||
|
var retry = 15000; // 15 secs for general errors
|
||||||
if (rc == 420) {
|
if (rc == 420) {
|
||||||
node.status({fill:"red", shape:"ring", text:"Rate limit hit"});
|
node.status({fill:"red", shape:"ring", text:"Rate limit hit"});
|
||||||
|
retry = 60000; // 60 secs for rate limit
|
||||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
//node.warn(RED._("twitter.errors.ratelimit"));
|
||||||
} else {
|
} else {
|
||||||
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
|
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
|
||||||
}
|
}
|
||||||
if (node.restart) {
|
if (node.restart) {
|
||||||
tout = setTimeout(setupStream(),15000);
|
node.tout = setTimeout(function() { setupStream() },retry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('destroy', function (response) {
|
stream.on('destroy', function (response) {
|
||||||
if (node.restart) {
|
if (node.restart) {
|
||||||
node.warn(RED._("twitter.errors.unexpectedend"));
|
node.warn(RED._("twitter.errors.unexpectedend"));
|
||||||
tout = setTimeout(setupStream(),15000);
|
node.tout = setTimeout(function() { setupStream() },15000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -261,7 +262,7 @@ module.exports = function(RED) {
|
|||||||
if (this.user === "false") {
|
if (this.user === "false") {
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
if (this.tags === '') {
|
if (this.tags === '') {
|
||||||
if (tout) { clearTimeout(tout); }
|
if (node.tout) { clearTimeout(node.tout); }
|
||||||
if (this.stream) {
|
if (this.stream) {
|
||||||
this.restart = false;
|
this.restart = false;
|
||||||
node.stream.removeAllListeners();
|
node.stream.removeAllListeners();
|
||||||
@ -300,6 +301,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.on('close', function() {
|
this.on('close', function() {
|
||||||
|
if (node.tout) { clearTimeout(node.tout); }
|
||||||
if (this.stream) {
|
if (this.stream) {
|
||||||
this.restart = false;
|
this.restart = false;
|
||||||
node.stream.removeAllListeners();
|
node.stream.removeAllListeners();
|
||||||
|
Loading…
Reference in New Issue
Block a user