python-3.xdiscord.py

Discord.py Bot keeps reconnected and disconnecting from voice channels


Very recently my discord bot has been unable to connect to voice channels. When I attempt to make it join it connects and then disconnects with the following error.

Traceback (most recent call last):
  File ".venv/lib/python3.11/site-packages/discord/voice_state.py", line 413, in _inner_connect
    await self._handshake_websocket()
  File ".venv/lib/python3.11/site-packages/discord/voice_state.py", line 583, in _handshake_websocket
    await self.ws.poll_event()
  File ".venv/lib/python3.11/site-packages/discord/gateway.py", line 1037, in poll_event
    raise ConnectionClosed(self.ws, shard_id=None, code=self._close_code)
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4006

According to the discord error codes this should mean that the session is invalidated but I'm not sure how that could happen second within the bot joining a voice channel.

My discord.py version is 2.5.2


Solution

  • https://github.com/Rapptz/discord.py/pull/10210

    A bug report and fix is underway