Skip to content

failed to read packet #6

Open
Open

Description

@lepterion

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

  1. Create a voice connection using VoiceManager.CreateConn.
  2. Open the voice connection and set the speaking flag.
  3. 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

Activity

  1. topi314 commented on Dec 14, 2025

    @topi314
    Member

    I've never seen that issue and can't reproduce it either lol
    can you try https://github.com/disgoorg/disgo/tree/exp/increase-voice-receive-buffer?

  2. lepterion commented on Dec 14, 2025

    @lepterion
    Author

    I've never seencthat issue and can't reproduce it either lol can you try https://github.com/disgoorg/disgo/tree/exp/increase-voice-receive-buffer?

    I tried to use my existing code and I can not reproduce this issue right now as well. I didn't introduce any changes to the code. But I noticed that the discord voice server has switched since the last time I tried to use voice. The branch you shared also seems to work as expected.

  3. lepterion commented on Dec 15, 2025

    @lepterion
    Author

    I've never seen that issue and can't reproduce it either lol can you try https://github.com/disgoorg/disgo/tree/exp/increase-voice-receive-buffer?

    Hello again. Today I tried to use voice again, and the issue returned. The error is the same. The issue persists on your branch as well.

  4. topi314 commented on Dec 29, 2025

    @topi314
    Member

    I am pretty clueless why this is happening. If you want to debug this further maybe we can chat in discord. The invite link is in the readme

  5. lepterion commented on Dec 31, 2025

    @lepterion
    Author

    I am pretty clueless why this is happening. If you want to debug this further maybe we can chat in discord. The invite link is in the readme

    I am really interested in getting this bug fixed. I am not sure if I will be helpful enough, but I will message you on the Discord server in a couple of days.

  6. davfsa commented on Jan 1, 2026

    @davfsa
    Contributor

    Hey!

    Its possible I might have indirectly fixed this issue while working on DAVE: https://github.com/disgoorg/disgo/pull/506/changes#diff-658cf4be28f310e298f7c966d33b56e611777ba2f2d1270a845d1494aa9bdee5R302

    Would you mind installing disgo from the feature/dave branch and seeing if your issue is fixed? You don't have to actually setup DAVE support, just updating might be enough :)

  7. lepterion commented on Jan 1, 2026

    @lepterion
    Author

    Hey!

    Its possible I might have indirectly fixed this issue while working on DAVE: https://github.com/disgoorg/disgo/pull/506/changes#diff-658cf4be28f310e298f7c966d33b56e611777ba2f2d1270a845d1494aa9bdee5R302

    Would you mind installing disgo from the feature/dave branch and seeing if your issue is fixed? You don't have to actually setup DAVE support, just updating might be enough :)

    Hello. Tried that branch but unfortunately the error still occurs.

  8. topi314 commented on Feb 12, 2026

    @topi314
    Member

    can you see if this is resolved in https://github.com/disgoorg/disgo/releases/tag/v0.19.0?

  9. lepterion commented on Feb 27, 2026

    @lepterion
    Author

    can you see if this is resolved in https://github.com/disgoorg/disgo/releases/tag/v0.19.0?

    Hello. Sorry for a this long reply. Yes, it looks like this issue has indeed been resolved.

    However, I have noticed a differrent problem. Reading packet returns "failed to decrypt frame" error whenever there is a user with camera on, even if they are silent.

    Additionally, on a couple of occasions, the same error started occurring on every read after a user joined the bot when it had been alone in a voice channel for a long time (at least 4 hours).

  10. transferred this issue fromdisgoorg/disgoon Feb 27, 2026
  11. topi314 commented on Feb 27, 2026

    @topi314
    Member

    probably relevant here
    #5

  12. topi314 commented on Mar 8, 2026

    @topi314
    Member

    @lepterion

    However, I have noticed a differrent problem. Reading packet returns "failed to decrypt frame" error whenever there is a user with camera on, even if they are silent.

    I can't reproduce this
    is this still a thing? if so can you show it to me or something? idk

    Additionally, on a couple of occasions, the same error started occurring on every read after a user joined the bot when it had been alone in a voice channel for a long time (at least 4 hours).

    a few of those errors are "normal" since its a race condition if we get the keys first, or they send audio
    if it happens more than a few frames thats bad tho. Can you clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions