GithubHelp home page GithubHelp logo

Comments (9)

Nyatra avatar Nyatra commented on May 19, 2024 1

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:

WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL

Sets the interval, in milliseconds, to send a keep-alive packet over the connection. The default interval is 30000 (30 seconds). The minimum interval is 15000 (15 seconds). Using WinHttpSetOption to set a value lower than 15000 will return with ERROR_INVALID_PARAMETER.

Note The default value for WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL is read from HKLM:\SOFTWARE\Microsoft\WebSocket\KeepaliveInterval. If a value is not set, the default value of 30000 will be used. It is not possible to have a lower keepalive interval than 15000 milliseconds.

from discord.net.

Auralytical avatar Auralytical commented on May 19, 2024

If this is running on a Linux/OSX box, be sure to add the Discord gateway cert:
certmgr -ssl https://gateway.discord.gg

from discord.net.

foxbot avatar foxbot commented on May 19, 2024

Unable to Reproduce;

Copied your project.json, Program.cs
Using Discord.Net 0.9.2 from NuGet.
dotnet 1.0.0-preview1-002702

from discord.net.

Nyatra avatar Nyatra commented on May 19, 2024

I'm using:

  • Windows 10 Pro 64bit
  • Visual Studio 2015 Community
  • 1.0.0-preview1-002702
  • Latest version of Discord.net from the master branch on GitHub

I've attached the project with the issue. InactivityIssue.zip

Folder structure:
YourProjectsFolder\Discord.Net\src\Discord.Net
YourProjectsFolder\InactivityIssue\

I get the same issue when I dotnet publish -c Release and run it on a remote Windows Server 2012.

from discord.net.

Auralytical avatar Auralytical commented on May 19, 2024

Thanks, I was able to reproduce with your project, looking into it.

from discord.net.

Auralytical avatar Auralytical commented on May 19, 2024

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

from discord.net.

Xeevis avatar Xeevis commented on May 19, 2024

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

"System.Net.WebSockets.Client": "4.0.1-beta*",

(this requires adding MyGet into NuGet package sources)

https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

from discord.net.

Auralytical avatar Auralytical commented on May 19, 2024

I've talked to Discord about this, and they're going to fix this sometime on their end, adding support for keepalive packets. @jhgg

from discord.net.

Auralytical avatar Auralytical commented on May 19, 2024

This fix is live.

from discord.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.