Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #298 from jayjanssen/slack_reconnect
Browse files Browse the repository at this point in the history
Slack reconnect cleanup
  • Loading branch information
Ben Brown authored Aug 13, 2016
2 parents ea0bc59 + e2da914 commit 857fc15
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Slackbot_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = function(botkit, config) {
};

var pingIntervalId = null;
var lastPong = 0;
var retryBackoff = null;

// config.retry, can be Infinity too
Expand Down Expand Up @@ -69,7 +68,6 @@ module.exports = function(botkit, config) {
clearInterval(pingIntervalId);
}

lastPong = 0;
botkit.trigger('rtm_close', [bot, err]);

// only retry, if enabled, when there was an error
Expand Down Expand Up @@ -118,6 +116,7 @@ module.exports = function(botkit, config) {
};

bot.startRTM = function(cb) {
var lastPong = 0;
bot.api.rtm.start({
no_unreads: true,
simple_latest: true,
Expand Down Expand Up @@ -163,7 +162,9 @@ module.exports = function(botkit, config) {
pingIntervalId = setInterval(function() {
if (lastPong && lastPong + 12000 < Date.now()) {
var err = new Error('Stale RTM connection, closing RTM');
botkit.log.error(err)
bot.closeRTM(err);
clearInterval(pingIntervalId);
return;
}

Expand Down

0 comments on commit 857fc15

Please sign in to comment.