Incapamentum / Exalted-Sage

Discord bot that does API requests to retrieve a collection of daily achievements for the next day and pushes an alert when any that is in a watchlist shows up.
3 stars 0 forks source link

BUG - `System.Exception:WebSocket connection was closed` #41

Closed Incapamentum closed 1 year ago

Incapamentum commented 1 year ago

The following has always been encountered in prod but was never able to properly explain. Finally encountered it in dev, and can say it only occurred when it tried to send multiple messages in a short period of time. It could be related, so this should be further looked into:

19:15:03 Gateway     System.Exception: WebSocket connection was closed
 ---> Discord.Net.WebSocketClosedException: The server sent close 1000: ""
   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)
   --- End of inner exception stack trace ---
   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext()
19:15:03 Gateway     Disconnecting
19:15:03 Gateway     Disconnected
19:15:07 Gateway     Connecting
Incapamentum commented 1 year ago

Looking into prod, curiously enough I do see a similar error, but it's also different. I think the one i found in dev relates specifically to the CancellationToken, which is part of a new way of doing the PeriodicAsync function.

For the sake of documentation, the change was originally done in 4f923b76a3584da458c3c7f95e7d63d8c9d1f558, before it had to be "reverted" in 6cb8087b5888e8ad6ebae0745e3e56d5bf6de2ea due to the VPS service at the time (which was Something.Host) not supporting .NET 6.0. The PeriodicAsync function was restored to how it was first done in 08208b573bd2cf3b0b1d85938ecbb0e658cfef7a.

Please check and see if there's a better way of handling this.

Incapamentum commented 1 year ago

Closing this issue as the PeriodicAsync() method is (probably) deprecated.

Please see #42 and #68 for reference and history, as they are (possibly) related.