diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d76398448..6f81d6e435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,6 +140,9 @@ These changes are available on the `master` branch, but have not yet been releas ([#2843](https://github.com/Pycord-Development/pycord/pull/2843)) - Fixed `TypeError` when using `@option` with certain annotations and along with `channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835)) +- Fixed reconnection issues with `VoiceClient` due to incorrectly trying to reconnect + with status code `4014`. + ([#2870](https://github.com/Pycord-Development/pycord/pull/2870)) ### Changed diff --git a/discord/voice_client.py b/discord/voice_client.py index a60d730413..2ff523cf0e 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -465,10 +465,7 @@ async def poll_voice_ws(self, reconnect: bool) -> None: await self.ws.poll_event() except (ConnectionClosed, asyncio.TimeoutError) as exc: if isinstance(exc, ConnectionClosed): - # The following close codes are undocumented, so I will document them here. # 1000 - normal closure (obviously) - # 4014 - voice channel has been deleted. - # 4015 - voice server has crashed, we should resume if exc.code == 1000: _log.info( "Disconnecting from voice normally, close code %d.", @@ -476,21 +473,15 @@ async def poll_voice_ws(self, reconnect: bool) -> None: ) await self.disconnect() break + # 4014 - Disconnect individual client (you were kicked, the main gateway session was dropped, etc.). if exc.code == 4014: _log.info( - "Disconnected from voice by force... potentially" - " reconnecting." - ) - successful = await self.potential_reconnect() - if successful: - continue - - _log.info( - "Reconnect was unsuccessful, disconnecting from voice" - " normally..." + "Disconnected from voice by force, close code %d.", + exc.code, ) await self.disconnect() break + # 4015 - The server crashed. Our bad! Try resuming. if exc.code == 4015: _log.info("Disconnected from voice, trying to resume...")