discordgo icon indicating copy to clipboard operation
discordgo copied to clipboard

How to use Discord's reconnection mechanism?

Open linliyuan opened this issue 4 months ago • 0 comments

I found that there is relevant information in the documentation https://discord.com/developers/docs/topics/gateway#resuming, but there is no corresponding implementation method in the third-party package. Can this recovery mechanism be added? Currently, sessionID, sequence, and gateway are all private, which prevents me from obtaining the last sequence of websocket events. The adjustments needed are quite large. I saw that there were several merge requests related to this, what was the reason for finally closing them? merge requests: https://github.com/bwmarrin/discordgo/pull/1327 https://github.com/bwmarrin/discordgo/pull/1115

And the following piece of code is quite strange, the reconnection judgment is before ready, which inevitably leads to the sessionID and sequence in the newly created session being 0. Send Op 6 Resume Packet can only possibly be executed in the case of a reconnect.

image

The current background is: the program cannot always run normally. If the service encounters an exception, I hope that the unprocessed data during the restart can be re-obtained through the recovery mechanism.

linliyuan avatar Feb 28 '24 07:02 linliyuan