lavalink-devs / Lavalink

Standalone audio sending node based on Lavaplayer.
https://lavalink.dev/
MIT License
1.56k stars 673 forks source link

Lavalink Server does not acknowledge that the voice websocket is closed when a shard is disconnected #177

Closed itslukej closed 4 years ago

itslukej commented 5 years ago

Issue: Lavalink Server does not acknowledge when the voice websocket is closed due to a shard being disconnected. It also does not send a WebSocketClosedEvent, which is how I discovered this issue.

Steps to reproduce: 1) Join the bot into a voice channel 2) Kill the bot's discord connection, whilst keeping the Lavalink socket open 3) Notice the bot has been removed from the voice channel 5) Notice nothing in the Lavalink Server logs and no events sent to the Lavalink Client

Thewsomeguy commented 5 years ago

Can reproduce.

DoNotSpamPls commented 5 years ago

Can reproduce.

freyacodes commented 5 years ago

Perhaps Discord is keeping the websocket open. I haven't read any documentation by Discord for what is the intended behavior is.

A workaround is to rely upon, your shard's lifecycle within the client, rather than the disconnect event. In my client, the disconnect event is used to renew expired sessions.

Yucked commented 5 years ago

Which sessions need to be renewed? Lavalink or discord's? And what is a shard life cycle and how'd a wrapper utilize it to avoid those issues?

freyacodes commented 5 years ago

@Yucked

  1. The Lavalink WS connection to the voice server
  2. The lifecycle of the bot's WS to the main gateway (independent of Lavalink)
MinnDevelopment commented 5 years ago

Discord is sending a close 4014: DISCONNECT when the session is closed. This should not be reconnected but magma does attempt to resume the session which has been fixed in a newer version. See version 0.9.2

schnapster commented 5 years ago

4014 | Disconnected | Oh no! You've been disconnected! Try resuming.

https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes

:thinking:

Guess that resume is aimed at the main WS connection then.

MinnDevelopment commented 5 years ago

@napstr the documentation is wrong.

MinnDevelopment commented 5 years ago

The 4014 close code is an indication that the voice connection was closed because it can no longer exist.

Example:

MinnDevelopment commented 5 years ago

@napstr I have updated the official docs for this as well: https://github.com/discordapp/discord-api-docs/commit/8ecc02e17b4dc409bd9c8b0bb21c670bd53fd305

In case you want to change your handling too.

schnapster commented 5 years ago

Thanks for the headsup @MinnDevelopment. As I mentioned in the JDA server the other day I was a total idiot about the Java 8 Magma thing. We should discuss getting all the stuff into a single repo, please contact me on Discord if you have interest and time.

schnapster commented 4 years ago

As per Minn's comments above, this should be fixed since a few versions ago in Magma. Please reopen if still an issue.