-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocketClient's KeepAliveInterval can't be disabled. #60
Comments
If this is running on a Linux/OSX box, be sure to add the Discord gateway cert: |
Unable to Reproduce; Copied your project.json, Program.cs |
I'm using:
I've attached the project with the issue. InactivityIssue.zip Folder structure: I get the same issue when I |
Thanks, I was able to reproduce with your project, looking into it. |
This appears to be tied to WebSocketClient's built-in KeepAliveInterval, which runs every 30 seconds of no activity. I tried disabling it on my end, but if you look at https://github.com/dotnet/corefx/blob/master/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs#L131 - I don't see this option being used anywhere. EDIT: Found an issue for this: https://github.com/dotnet/corefx/issues/5116 |
This can be really frustrating issue as bot on low traffic guilds is coming on/off all the time missing commands and events. I've managed to over come this by deploying to docker on Synology NAS (any Linux environment should work), where it works flawlessly. Since stable release of WebSockets.Client doesn't support unix yet, it's necessary to download latest beta version from https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Net.WebSockets.Client Or bump Discord.Net/projects.json dependency to
(this requires adding MyGet into NuGet package sources)
|
The way I worked around the issue on Windows for now, is by setting the global Keep-alive Interval in the registry to something really large. HKLM:\Software\Microsoft\WebSocket\KeepaliveInterval It's should be a DWORD, if it does not exist already. This will affect anything that uses the global setting and does not have it's own setting. (All .NET Core WebSockets currently) I found this in an msdn page:
|
I've talked to Discord about this, and they're going to fix this sometime on their end, adding support for keepalive packets. @jhgg |
This fix is live. |
discord-net#60) * Add new `NUMBER` option type (https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type) https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type * Add number to SocketSlashCommandDataOption.cs
In console window (OnLogMessage from DiscordBot):
[Gateway] Disconnected: Received close code 4002: Error while decoding payload.
In Visual Studio output window:
This occurs every 32.5 seconds when there is absolutely no activity in connected channels.
With activity, this does not occur.
After disconnecting, Discord.Net reconnects and, if there is still no activity, it disconnects again after 32.5 seconds.
Guessing it has something to do with the heartbeat.
Using .Net Core RC2. Latest master branch from GitHub.
project.json:
Program.cs:
The text was updated successfully, but these errors were encountered: