lavacord / Lavacord

A easy to use Lavalink client that can be used with any discord api wrapper
Apache License 2.0
79 stars 21 forks source link

Code 4006 Session Error #75

Closed burakmosby closed 1 year ago

burakmosby commented 4 years ago

When the bot enter the voice channel for the first time, it giving the following error: { op: 'event', reason: 'Session is no longer valid.', code: 4006, byRemote: true, type: 'WebSocketClosedEvent', guildId: '652877747621986348' }

After this error, I turn the bot off and on and when I enter the command to play music again, the music plays successfully. But after the bot exits from the voice channel and enters the music command again, this error occurs again.

TristanWasTaken commented 3 years ago

The code 4006 means that the bot didn't exit the voice channel correctly. Discord gives voice connections a session ID. If the bot times out or disconnects from the gateway, Discord assumes the connection is inactive and that your bot will try to connect with a new session id. When your bot connects to a voice channel, it should replace the old session ID with a new one (see Manager.ts).

It works if you restart your bot because you kill your bot process and delete the cached connection id with it. I assume it should be a bug in your bot.