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

ECONNRESET error #88

Closed jaredfox closed 5 years ago

jaredfox commented 6 years ago

I am running the bot on a Ubuntu 18.04 Linux VPS and its stopping on its own. I checked the nohup.out for the error and im getting this

events.js:167 throw er; // Unhandled 'error' event ^

Error: closed before the connection is established at WebSocket.terminate (/root/modmail/master/node_modules/ws/lib/WebSocket.js:389:21) at Shard.disconnect (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:102:25) at Timeout.setTimeout [as _onTimeout] (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:1647:22) at ontimeout (timers.js:427:11) at tryOnTimeout (timers.js:289:5) at listOnTimeout (timers.js:252:5) at Timer.processTimers (timers.js:212:10) Emitted 'error' event at: at Shard.emit (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:1877:26) at Shard.disconnect (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:113:18) at Timeout.setTimeout [as _onTimeout] (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:1647:22) [... lines matching original stack trace ...] at Timer.processTimers (timers.js:212:10)

Dragory commented 6 years ago

This looks like a network error/timeout of some sort. Make sure there isn't a firewall preventing connections to Discord's servers somewhere.

jaredfox commented 6 years ago

The VPS doesn't have a firewall or anything blocking the port its using. I just had it die again and this error was present

Error: read ECONNRESET at TLSWrap.onread (net.js:656:25) Emitted 'error' event at: at Shard.emit (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:1877:26) at WebSocket.ws.onerror (/root/modmail/master/node_modules/eris/lib/gateway/Shard.js:1600:18) at WebSocket.onError (/root/modmail/master/node_modules/ws/lib/EventTarget.js:109:16) at WebSocket.emit (events.js:182:13) at WebSocket.finalize (/root/modmail/master/node_modules/ws/lib/WebSocket.js:182:41) at TLSSocket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19)

Dragory commented 6 years ago

Hey, sorry for the delay on this. These errors definitely seem like network errors of some sort between the bot and the Discord API. Unfortunately I'm not able to do much to fix them from my end - you might want to ask your VPS provider if they can help you out with this.

jaredfox commented 6 years ago

I moved the bot over to its own seperate VPS from my other services im running and still ended up stopping with this error

events.js:183 throw er; // Unhandled 'error' event ^

Error: read ECONNRESET at _errnoException (util.js:992:11) at TLSWrap.onread (net.js:618:25) ~

I sent in a ticket to DigitalOcean to see if it is indeed something network related on their end since I don't have networking or firewall turned on for that vps.

Dragory commented 6 years ago

I just pushed a new update that might help with this. Can you try with v2.16.0?

jaredfox commented 6 years ago

updated and will keep an eye out. usually only happens after a week or so.

brandonbayliss8 commented 6 years ago

I had this error again 2 days after upgrading

brandonbayliss8 commented 6 years ago

events.js:188 throw err; ^

Error: Unhandled "error" event. ([object Object]) at CommandClient.emit (events.js:186:19) at Shard.emit (/root/modmailbot/node_modules/eris/lib/gateway/Shard.js:18 82:26) at WebSocket.ws.onerror (/root/modmailbot/node_modules/eris/lib/gateway/S hard.js:1605:18) at WebSocket.onError (/root/modmailbot/node_modules/ws/lib/event-target.j s:128:16) at emitOne (events.js:116:13) at WebSocket.emit (events.js:211:7) at ClientRequest.req.on (/root/modmailbot/node_modules/ws/lib/websocket.j s:535:10) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

Dragory commented 6 years ago

I will be pushing an update to help with the ECONNRESET errors sometime after next week. Until then, I recommend using an auto-restart utility of some sort, such as pm2.

sporkwitch commented 6 years ago

While a bit brute force, it should be possible to simply catch the exception, log the error, and make x number of progressively delayed reconnection attempts. Unless you're seeing some details I'm not, it seems to just be some random loss or discord having a hiccough