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

Slack reconnect cleanup #298

Merged
merged 3 commits into from
Aug 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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