Skellington-Closet / skellington

:sparkles::skull::sparkles: The skeleton for your bots
MIT License
64 stars 6 forks source link

RTM connections timeout and don't restart #48

Open colestrode opened 7 years ago

colestrode commented 7 years ago

I've observed this on single-team bots, but I'm sure this would affect Slack apps as well. After some time, the RTM connection times out, I believe because the pong response doesn't come back after a timeout. This is the error logged:

Error: Stale RTM connection, closing RTM
    at Timeout.pinger [as _onTimeout] (/Users/cfurfarostrode/src/projects/pizza-bot/node_modules/botkit/lib/Slackbot_worker.js:182:35)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

It would be good to catch that error and try to reconnect. If we can't reconnect, exit (if single team bot and option is set) or at the very least log something out in the logs. It would be good to include any team information we have, though we might not have any in that error.