-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Slack RTM retry/reconnect not working #261
Comments
Hi, I have been having issues with my slack connection just going dark as well and with your suggestion of tcpkilling the connection, I found a few issues that I tried to fix here: I'm not sure if it addresses your specific issue or not, but once I was logging properly (#299), I was able to see slackbot do reconnection attempts with tcpkill. |
Ah, this looks like the issue I'm having upon hitting a debug breakpoint. I don't know enough about @jayjanssen's PR but it definitely touches what I'm seeing go wrong with reconnects. |
I'm using v0.4 that includes the fix above, but also found this in logs:
After this no messages reach slack and the bot is offline, so the issue is still there. |
For anyone looking for a reliable solution, I have auto-reconnect disabled and use the following code to keep the bot alive. It hasn't failed once since my last reply here. var controller = ...;
var bot = ...;
function start_rtm() {
bot.startRTM(function(err,bot,payload) {
if (err) {
console.log('Failed to start RTM')
return setTimeout(start_rtm, 60000);
}
console.log("RTM started!");
});
});
}
controller.on('rtm_close', function(bot, err) {
start_rtm();
});
start_rtm(); Hope it helps! Edit: There's no need to handle |
@garymoon How do I disable auto-reconnect? |
@rickul It's disabled by default, I just meant I don't have it enabled when I use the code above. |
Thanks! Your code works fine 👍 |
Closed as answered |
Probably best to remove the feature if there's no interest in fixing it @peterswimm. |
@garymoon with the shift from rtm to events you may see a deprecation of this feature, but if anyone has a PR that improves functionality of auto-reconnect we will definitely consider it. |
@peterswimm My understanding is that events and RTM are intended to compliment one another, indeed each has several features not supported by the other. It seems that silent disconnects are causing some confusion for those using RTM with botkit (myself included). With some guidance on what would be expected of a PR to resolve this issue (assuming transplanting my solution above into the library itself is undesirable) I believe I'd be able to submit a working PR. |
I tried @garymoon code and I went to a issue, at some points it started twice and two websockets were opened. I didn't enable "retry", looks like it goes to this code |
@xuanvinh2005 After struggling with this, I found this bug and created this PR Very simple change from bot to botkit. Reconnect has been working flawlessly since. Also using the following code to notify me in slack of reconnects, drops, and other slack RTM messages.
|
About retry stuff, I have workaround by setting retry when calling spawn instead of in botkit config, however, my issue is the same with @rdohms's error: Error: Stale RTM connection, closing RTM |
Had the same issue but once I fixed the bug in Slackbot_worker.js it has been working fine and haven't had any issues in the last month. Just to make sure, I logged the status of the retryEnabled attribute in the closeRTM function in Slackbot_worker.js. With the above change, it was always true for the stale connection error and haven't had any issues since. Hope this helps.
|
Hi,
I've found that the RTM reconnect logic isn't reached when the RTM connection dies for one reason or another.
Version: 0.1.2
OS: Ubuntu 15.04
Node: v6.1.0
To test I have done the following:
retry
to 5 in my controller configconsole.log
'd theretryEnabled
var inSlackbot_worker.js
to ensure it was setconsole.log
'd at the start ofreconnect()
tcpkill
'd the RTM connectionThis follows a series of less drastic actions to confirm it wasn't working.
It seems the only path to the retry logic is at the bottom of
bot.closeRTM
when an err object is passed. This code is not reached from theerror
orclose
event ofbot.rtm
which is the path followed when the connection dies unexpectedly. I am unsure whether or not it is desirable to callreconnect()
fromclose
, so I've not submitted a PR. I'm happy to once it's been clarified what would be desired. As a user I would probably expect the retry logic to occur on ateam_migration_started
event also, though I suspect that would be be immediately followed by aclose
event as per the Slack documentation.Thank you for botkit, it's great stuff!
Cheers,
Gary.
The text was updated successfully, but these errors were encountered: