Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice woes: moving channels via client drag and region changes break voice connection #9364

Closed
3 tasks done
imayhaveborkedit opened this issue Apr 17, 2023 · 2 comments · Fixed by #9525
Closed
3 tasks done
Labels
bug This is a bug with the library.

Comments

@imayhaveborkedit
Copy link
Contributor

imayhaveborkedit commented Apr 17, 2023

Summary

Voice code does not properly reconnect to voice upon being moved to a different channel and possibly from a region change.

Reproduction Steps

Join the bot to voice channel A. Then either:

  • Drag the bot to voice channel B
  • Drag the bot back to voice channel A (or any other)

or

  • Change the voice region

Minimal Reproducible Code

Mostly reproduced in the client but there is one peculiar thing to note. Dragging the bot between channels in the client breaks it differently than moving channels with voice_client.move_to. For example:

vch1 = guild.get_channel(123)
vch2 = guild.get_channel(456)

await vc = vch1.connect()
await vc.move_to(vch2)
await vc.move_to(vch1)
await vc.move_to(vch2)
await vc.move_to(vch1)
await vc.move_to(vch2)
await vc.move_to(vch1)

The bot seemingly changes channel properly, however the log output is a bit strange. See footnote 1.

In the other case, it's simply changing the voice region via client or await channel.edit(rtc_region="..."). See footnote 2.

Expected Results

Naturally, it should just work.

Actual Results

Bizarre breakage and bad connection state.

Intents

All

System Information

  • Python v3.11.3-final
  • discord.py v2.2.2-final
  • aiohttp v3.8.4
  • system info: Windows 10 10.0.19045

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I'm fairly sure this is a regression and I don't know if it has anything to do with 21ed9f6, but I'll look into this more later.

Additionally, one other person has tried this in the discord server and their breakage is different from mine. See: https://discord.com/channels/336642139381301249/336642776609456130/1097363280332337263 and the video shortly after that.

[1]

[2023-04-17 00:13:04] [INFO    ] discord.voice_client: Connecting to voice...
[2023-04-17 00:13:04] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 1)
[2023-04-17 00:13:04] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east6118.discord.media
[2023-04-17 00:13:13] [INFO    ] discord.voice_client: Disconnected from voice by force... potentially reconnecting.
[2023-04-17 00:13:13] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 2)
[2023-04-17 00:13:13] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east7023.discord.media
[2023-04-17 00:13:23] [INFO    ] discord.voice_client: Disconnected from voice by force... potentially reconnecting.
[2023-04-17 00:13:23] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 3)
[2023-04-17 00:13:23] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east5289.discord.media
[2023-04-17 00:13:43] [INFO    ] discord.voice_client: Disconnected from voice by force... potentially reconnecting.
[2023-04-17 00:13:43] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 4)
[2023-04-17 00:13:43] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east7388.discord.media
[2023-04-17 00:13:48] [INFO    ] discord.voice_client: Disconnected from voice by force... potentially reconnecting.
[2023-04-17 00:13:48] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 5)
[2023-04-17 00:13:48] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east4334.discord.media
Unclosed connection
client_connection: Connection<ConnectionKey(host='us-east6118.discord.media', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
Unclosed connection
client_connection: Connection<ConnectionKey(host='us-east7023.discord.media', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
Unclosed connection
client_connection: Connection<ConnectionKey(host='us-east5289.discord.media', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
Unclosed connection
client_connection: Connection<ConnectionKey(host='us-east7388.discord.media', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
[2023-04-17 00:13:52] [INFO    ] discord.voice_client: Disconnected from voice by force... potentially reconnecting.
[2023-04-17 00:13:52] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 6)
[2023-04-17 00:13:52] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east7023.discord.media

[2]

I'm not entire sure if the state here is broken, but there is a ws close exception with code 4000 for me.

[2023-04-17 00:26:17] [INFO    ] discord.voice_client: Connecting to voice...
[2023-04-17 00:26:17] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 1)
[2023-04-17 00:26:17] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found us-east6442.discord.media
[2023-04-17 00:26:32] [ERROR   ] discord.voice_client: Disconnected from voice... Reconnecting in 1.87s.
Traceback (most recent call last):
  File "C:\Python\Python3.11\Lib\site-packages\discord\voice_client.py", line 456, in poll_voice_ws
    await self.ws.poll_event()
  File "C:\Python\Python3.11\Lib\site-packages\discord\gateway.py", line 1006, in poll_event
    raise ConnectionClosed(self.ws, shard_id=None, code=self._close_code)
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4000
[2023-04-17 00:26:34] [INFO    ] discord.voice_client: The voice handshake is being terminated for Channel ID 124808142688092160 (Guild ID 124808140838404096)
[2023-04-17 00:26:34] [INFO    ] discord.voice_client: Connecting to voice...
[2023-04-17 00:26:34] [INFO    ] discord.voice_client: Starting voice handshake... (connection attempt 2)
[2023-04-17 00:26:34] [INFO    ] discord.voice_client: Voice handshake complete. Endpoint found japan11113.discord.media
@imayhaveborkedit imayhaveborkedit added the unconfirmed bug A bug report that needs triaging label Apr 17, 2023
@sedley
Copy link

sedley commented Apr 18, 2023

I am having this issue as well, but it's affecting me when the client is disconnected by another user.

@codeofandrin
Copy link
Contributor

codeofandrin commented Apr 18, 2023

Wenn dragging it in the client, I can't reproduce the Unclosed connection output. When I want to move with move_with I get this warning after 2 moves:

WARNING  discord.gateway Shard ID None has stopped responding to the gateway. Closing and restarting.

So I can't really reproduce your errors

@Rapptz Rapptz added bug This is a bug with the library. and removed unconfirmed bug A bug report that needs triaging labels Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug with the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants