Dragory / modmailbot

Modmail Bot is a bot for Discord that makes it easier for users to contact moderators and admins for help.
MIT License
709 stars 703 forks source link

[Suggestion] Attempt reconnect after network interruption. #571

Closed Mondrethos closed 1 year ago

Mondrethos commented 3 years ago

Hi,

When the bot servers from any network interruption, the process crashes. It would be preferred if it instead waited and retried over a period of a few minutes at least. If it continues to fail, it should exit cleanly at some point (preferably confirgurable)

Dragory commented 3 years ago

The bot currently reconnects automatically on any of the following network errors:

Are you experiencing a specific error that isn't automatically reconnecting?

Mondrethos commented 3 years ago

Hi Dragory,

I experience this one regularly and have to manually start the bot again.

Error: Error: Server didn't acknowledge previous heartbeat, possible lost connection
    at Shard.heartbeat (/home/wizard/modmail/node_modules/eris/lib/gateway/Shard.js:303:20)
    at Timeout.<anonymous> (/home/wizard/modmail/node_modules/eris/lib/gateway/Shard.js:424:69)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! modmailbot@3.2.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the modmailbot@3.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/wizard/.npm/_logs/2021-03-10T07_01_49_325Z-debug.log
crckhub commented 3 years ago

Hello, I have had frequent issues with Discord API timeouts, so I started using PM2 (a process manager) to automatically restart the bot when it stopped. You should look into that as well if you are not using it yet, it's very useful as you can monitor and restart the bot from a web browser and the pm2-discord module can send the console output produced by the bot via a Discord webhook straight to a Discord channel. This fixed my issues with network disconnects / timeouts, maybe it can help you as well if you are not already using PM2