question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discord.Net doesn't automatically reconnect after network disconnect

See original GitHub issue
2018-02-22 14:06:21|INFO|ArchiBoT|OnLog() Discord | Discord.Net v2.0.0-beta (API v6)
(...)
2018-02-22 15:26:11|WARN|ArchiBoT|OnLog() Gateway |
2018-02-22 15:26:11|WARN|ArchiBoT|OnLog() System.Exception: Server missed last heartbeat
   at Discord.ConnectionManager.<>c__DisplayClass28_0.<<StartAsync>b__0>d.MoveNext()
2018-02-22 15:26:11|INFO|ArchiBoT|OnLog() Gateway | Disconnecting
2018-02-22 15:26:12|INFO|ArchiBoT|OnLog() Gateway | Disconnected
2018-02-22 15:26:13|INFO|ArchiBoT|OnLog() Gateway | Connecting
2018-02-22 15:27:58|INFO|ArchiBoT|OnLog() Gateway | Disconnecting
2018-02-22 15:27:58|INFO|ArchiBoT|OnLog() Gateway | Disconnected

Library properly attempted to reconnect after missing last heartbeat, but it seems like it failed with timeout after those ~45 seconds and decided to stop further attempts. According to https://github.com/RogueException/Discord.Net/commit/73ac9d7886aa48b9d809c56e51945056f3b67232 - similar issue should be already solved for 2.0.0-beta, but it seems that this issue is still recent in one form or another.

It should definitely keep on trying until it succeeds, unless this is somehow intended (in this case how we should handle it ourselves?)

Thank you in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:59 (24 by maintainers)

github_iconTop GitHub Comments

9reactions
HunterGraubardcommented, Jul 6, 2018

I’ve just started using Discord.Net in a project and have immediately noticed this issue. I have a bot that starts up and runs LoginAsync() and then StartAsync(). It connects and works fine. However, after some number of hours, I notice the bot has gone offline on Discord, and my console log displays Gateway: Disconnected. That’s it. There are no other messages about a heartbeat, and it literally never, ever, ever attempts to reconnect. It always disconnects after a while, and it never reconnects.

When this happens, the bot stays offline on Discord, and no longer responds to PMs. However, curiously, it is still able to send automated messages to a channel via SendMessageAsync() despite being offline.

My only solution to get the bot fully online again is to restart it completely. This is quite annoying to have to do every single day. Sometimes I have to do it multiple times per day.

4reactions
SubZero0commented, Jun 15, 2021

I just merged two fixes to possible deadlocks, #1872 and #1873 They should deal with the valid reports that I read here.

These changes are effective in 2.4.1-dev and the latest 3.0.0-dev (so 3.0.0-dev-20210615.5) that are available in MyGet. Please use these before reporting any other deadlock.

As a note, the websocket connection being closed and reconnecting isn’t a deadlock or an issue at all. If it reconnected, it’s working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discord.net C# Bot - A few shards connect and disconnect ...
It usually means the bot has hung up somewhere and cannot respond back to Discord. Usually the bot does not reconnect when it...
Read more >
Managing Connections | Discord.Net Documentation
In Discord.Net, once a client has been started, it will automatically maintain a connection to Discord's gateway until it is manually stopped.
Read more >
[Fixed]: Discord Keeps Disconnecting and Reconnecting
A slow internet connection can lead to interruptions while connecting to the Discord servers. · To do so, just go to Speedtest and...
Read more >
Discord Keeps Disconnecting and Reconnecting? 15 Ways ...
1. Check the Discord Server Status · 2. Check Your Network Connection · 3. Update Discord to Its Latest Version · 4. Force-Quit...
Read more >
Discord Keeps Disconnecting - Here's How To Fix?
Method 1: Check Discord Servers · Method 2: Use all your Networks · Method 3: Disable your VPN · Method 4: Flush DNS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found