Skip to content
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

Voice WebSocket Connection closed with 4014 when switching voice channels #2450

Closed
angelobreuer opened this issue Jan 4, 2021 · 6 comments
Closed
Labels

Comments

@angelobreuer
Copy link
Contributor

angelobreuer commented Jan 4, 2021

Description
On some servers, the Voice WebSocket connection is closed with 4014 Disconnected when the bot is moved around in voice channels. The discord app also receives the same close code on these servers. I think that we should either document that the close code 4014 Disconnected is used for server changes, or discord could introduce a new close code.

Steps to Reproduce

  1. Open the developer console of the discord client (or use your bot with payload tracking enabled).
  2. Connect to a voice channel (for example, one of the unofficial discord API server).
  3. Connect to another voice channel in the same guild.
  4. Observe.

Expected Behavior / Alternatives considered

  • Document that the voice connection is closed with a 4014 Disconnected when the voice server changes.
  • Let the voice connection close with a new close code when the voice server changes (for example, 4017 Switching voice server).
  • There should be no voice server change, which can be due to load balancing or choosing a voice server that is more optimal for the users in the channel.

Current Behavior

  • On particular servers (I think mostly servers that have the community feature enabled for some time), I am receiving a 4014 Disconnected when switching voice channels.

Why is this needed

  • I think that we should be able to distinguish between a voice server change and a kick, gateway session-invalidation, or a channel deletion. This is useful to improve resource management for clients. Currently, clients have to listen for the following VOICE_SERVER_UPDATE payload to decide whether the connection handle should be freed or reused.

Screenshots/Videos

Discord.2021-01-04.10-49-49.mp4

Client and System Information

Stable 73806 (0c3eadc)
Host 0.0.309
Windows 10 64-Bit (10.0.19042)

@MinnDevelopment
Copy link
Contributor

MinnDevelopment commented Jan 4, 2021

I think there should be no reconnect as the voice server remains the same.

If you carefully read the logs you show in your video, you can tell that this is not true. Bigger servers do not use the same voice server for all channels. The connection is closed because the server is changing. Making a new close code would be breaking for existing implementations, such as JDA which rely on the current behavior.

@angelobreuer
Copy link
Contributor Author

angelobreuer commented Jan 4, 2021

I think there should be no reconnect as the voice server remains the same.

If you carefully read the logs you show in your video, you can tell that this is not true. Bigger servers do not use the same voice server for all channels. The connection is closed because the server is changing.

I have updated my issue to the previous version, but I did not realize that the voice server changed (I was looking at the wrong IP). Thanks for clarification 👍

Making a new close code would be breaking for existing implementations, such as JDA, which rely on the current behavior.

I surely agree with that, but I think that documenting this behavior (which was my original intention for this issue) should be done because I think it is confusing that a 4014 Disconnected is dispatched for a voice channel change.

@night
Copy link
Contributor

night commented Apr 9, 2021

this will be documented for the close code in the next docs deploy

@night night closed this as completed Apr 9, 2021
@james58899
Copy link

Why should not reconnect after voice server changed?
Should not reconnect to old voice server or not reconnect to voice gateway?

| 4014 | Disconnected | Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect. |

@qaisjp
Copy link
Contributor

qaisjp commented Apr 11, 2021

You can teach your bot to reconnect to the voice channel when the voice server is changed.

My guess (I haven't used the voice API before) is that this feature isn't provided by the API because transparently reconnecting in the backend is not possible — your client needs to connect to a different voice endpoint.

@james58899
Copy link

kick and voice server change have same code, if try reconnect it will rejoin voice channel after kick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants