lavacord/Lavacord

Code 4006 Session Error

croxydev opened this issue · 1 comments

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.

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.