Describe the bug
Calling UDPConn.ReadPacket() consistently fails when reading from a Discord voice UDP connection. The method almost never successfully reads a packet once the connection is opened.
Error
The following error is logged on every call to ReadPacket():
failed to read packet: read udp 192.168.0.108:61986->34.0.245.81:50006: wsarecv: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.
To Reproduce
- Create a voice connection using
VoiceManager.CreateConn.
- Open the voice connection and set the speaking flag.
- Continuously read packets from the voice UDP connection in a goroutine using
UDPConn.ReadPacket().
vs := global.Session.VoiceManager.CreateConn(guildID)
err := vs.Open(ctx, channelID, false, false)
if err != nil {
return fmt.Errorf("failed to open voice connection: %w", err)
}
err = vs.SetSpeaking(ctx, voice.SpeakingFlagMicrophone)
if err != nil {
return fmt.Errorf("failed to set speaking: %w", err)
}
go func() {
for {
_, err := vs.UDP().ReadPacket() // this fails
if err != nil {
slog.Error("error reading voice packet", "error", err)
continue
}
}
}()
Expected behavior
UDPConn.ReadPacket() should successfully read incoming UDP voice packets once the voice connection is established.
Disgo Version:
- v0.19.0-rc.12
- go 1.25.3 windows/amd64
Describe the bug
Calling
UDPConn.ReadPacket()consistently fails when reading from a Discord voice UDP connection. The method almost never successfully reads a packet once the connection is opened.Error
The following error is logged on every call to
ReadPacket():To Reproduce
VoiceManager.CreateConn.UDPConn.ReadPacket().Expected behavior
UDPConn.ReadPacket()should successfully read incoming UDP voice packets once the voice connection is established.Disgo Version: