bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.12k stars 817 forks source link

Gateway loosing connection and not reconnecting #899

Open lxi1400 opened 3 years ago

lxi1400 commented 3 years ago

After a while of our bot running, we receive this error:

2021/03/25 00:53:33 [DG0] wsapi.go:82:Open() error connecting to gateway wss://gateway.discord.gg/?v=6&encoding=json, dial tcp: i/o timeout
2021/03/25 00:53:33 [DG0] wsapi.go:835:reconnect() error reconnecting to gateway, dial tcp: i/o timeout
2021/03/25 00:53:33 [DG0] wsapi.go:302:heartbeat() error sending heartbeat to gateway wss://gateway.discord.gg/?v=6&encoding=json, websocket: close sent
2021/03/25 00:53:33 [DG0] wsapi.go:82:Open() error connecting to gateway wss://gateway.discord.gg/?v=6&encoding=json, dial tcp: i/o timeout
2021/03/25 00:53:33 [DG0] wsapi.go:835:reconnect() error reconnecting to gateway, dial tcp: i/o timeout

any ideas on how to go about this? It's so annoying having to constantly monitor if the bot is up or not, and it does this almost once per day

bwmarrin commented 3 years ago

I'd start with just making sure you're on the latest DiscordGo commit to just rule out some already fixed issue. Outside of that, the errors look like some kind of network issue which could be on your end, Discords end, or somewhere in the middle. It looks like it's trying to reconnect to Discord but the network connection is timing out.

How long does it keep trying to reconnect? Are there any panics or other errors in your logs that might help narrow down the issue some more?