Discord.Net: Operation timed out on `Discord.WebSocket.SocketGuild.ConnectAudioAsync`

Hi, since yesterday my bot stopped working with the following exception.

System.TimeoutException: The operation has timed out.
         at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
         at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
         at Discord.WebSocket.SocketVoiceChannel.ConnectAsync(Boolean selfDeaf, Boolean selfMute, Boolean external)
         at Template.Services.PlaybackService.CreateSession(IVoiceChannel channel) 

This is happening on two separate API keys and both when running the bot from my PC and a linux server. What could be the cause and how to fix this? I’ve tried updating Discord.Net to 3.9.0 but the issue persists.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Ref: “all apps with Voice Connections using IP Discovery must send 74-byte UDP packets. IP Discovery requests sending the deprecated 70-byte packet will no longer receive a response.” - Discord Dev API announcement. This change was rolled out yesterday.

Is it known when will the nuget get published with the fix? Seems like a pretty major issue when all voice apps stop working

Ref: “all apps with Voice Connections using IP Discovery must send 74-byte UDP packets. IP Discovery requests sending the deprecated 70-byte packet will no longer receive a response.” - Discord Dev API announcement. This change was rolled out yesterday.

I’ll coordinate a release within the next couple of days, sorry for the late fixes 😦

The fix for this has been pushed to the dev branch already but no build has been published to NuGet #2617

You have to add the nightly build package source to your NuGet package sources, then get the nightly builds from 2nd March 2023.

Feed URL: https://www.myget.org/F/discord-net/api/v3/index.json

Your csproj file should look like this when all’s done:

    <PackageReference Include="Discord.Net" Version="3.9.0-20230302.10" />
    <PackageReference Include="Discord.Net.Commands" Version="3.9.0-build-20230302.10" />
    <PackageReference Include="Discord.Net.Core" Version="3.9.0-build-20230302.10" />
    <PackageReference Include="Discord.Net.Interactions" Version="3.9.0-build-20230302.10" />
    <PackageReference Include="Discord.Net.Rest" Version="3.9.0-build-20230302.10" />
    <PackageReference Include="Discord.Net.Webhook" Version="3.9.0-build-20230302.10" />
    <PackageReference Include="Discord.Net.WebSocket" Version="3.9.0-build-20230302.10" />

Not the best solution, but if you need something while waiting for the official NuGet build, this works.

I had the same problem. I noticed that DiscordSocketClient in Log event says Unknown OpCode (Hello). After handling this case, the client stopped throwing timeout and started to connect.

file: Discord.Net.WebSocket\Audio\AudioClient.cs -> ProcessMessageAsync method

I just added: case VoiceOpCode.Hello: await _audioLogger.DebugAsync("Received Hello message").ConfigureAwait(false); break;