botkit icon indicating copy to clipboard operation
botkit copied to clipboard

Bot stops responding after some time...

Open gservat opened this issue 10 years ago • 8 comments

I'm running botkit within a container (on AWS, if it makes any difference) and I've noticed that -- without fail -- the bot will simply stop responding after "a while" ... which could be a day, two days, sometimes even 3-4 days. The process is not dead, the container is certainly not dead, but none of the commands defined will return anything anymore.

Absolutely nothing further is logged on the console once it stops responding, and no error messages prior to that.

Driving me insane. Anyone else had this? Node version 6.4.0.

gservat avatar Oct 13 '16 09:10 gservat

Just happened again after 4 days of uptime ... just stopped responding and nothing in the logs :(

gservat avatar Oct 18 '16 10:10 gservat

Looks like there are others having similar issues:

https://github.com/howdyai/botkit/issues/445 https://github.com/howdyai/botkit/issues/276

I am currently trying with the retry option to controller.spawn, and I've upgraded to v0.4. Will report back in a few days with the outcome.

gservat avatar Oct 20 '16 12:10 gservat

I would suggest you ask your question on dev4slack. Tips for bot uptime and keeping your bot running come up often there, and there are a number of good tips in the history.

peterswimm avatar Oct 20 '16 14:10 peterswimm

@gservat #261 might be helpful.

garymoon avatar Nov 12 '16 04:11 garymoon

@gservat did 0.4 solved this issue? I am having the same problem, but i can see it is happening only after a conversation is about to start (bot.StartConversation()).

vantonop avatar Nov 23 '16 17:11 vantonop

Struggled with this one for a while, found this bug and created this PR

https://github.com/howdyai/botkit/pull/532

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.

controller.on('rtm_close',function(bot) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' ** The RTM api just closed');

try {
controller.findTeamById('<SLACK_TEAM_ID_HERE>', function(err, team) {
var alertBot = controller.spawn(team);
alertBot.api.chat.postMessage(
{
channel : '<SLACK_CHANNEL_ID_HERE>',
text: 'GUYS!!! I just got an RTM Close event trigger for this team --> '+bot.team_info.id+' '+bot.team_info.name+' .',
attachments: [],
}, function (err, response) {
});
});
} catch (err) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' Tried to send alert for an rtm_close event but failed with this error: '+err);
}
});

controller.on('rtm_reconnect_failed',function(bot) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' ** Unable to automatically reconnect to rtm after a closed conection.');

try {
controller.findTeamById('<SLACK_TEAM_ID_HERE>', function(err, team) {
var alertBot = controller.spawn(team);
alertBot.api.chat.postMessage(
{
channel : '<SLACK_CHANNEL_ID_HERE>',
text: 'GUYS!!! I just got an RTM Reconnect Failed trigger for this team --> '+bot.team_info.id+' name: '+bot.team_info.name+'. The team either uninstalled the app or there was an issue which requires a resart of the bot.',
attachments: [],
}, function (err, response) {
});
});
} catch (err) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' Tried to send alert for an rtm_reconnect_failed event but failed with this error: '+err);
}
});

inn0v8 avatar Dec 08 '16 01:12 inn0v8

Apologies; "a few days" turned into "a few months". Yes, upgrading to 0.4 fixed it.

gservat avatar May 03 '17 05:05 gservat

Closing as resolved then! Thanks for the confirmation!

peterswimm avatar May 04 '17 17:05 peterswimm