Open
Description
Summary
When attempting a voice connection, the connection process gets stuck after completing the voice handshake and eventually times out without successfully connecting.
Reproduction Steps
- Attempt to connect to a voice channel using discord.py-self.
Observe the logs:
- "Voice handshake complete. Endpoint found: [region].discord.media."
- No follow-up "Voice connection complete."
After ~10 seconds, the client logs "Timed out connecting to voice."
Code
@bot.command()
async def joinvc(ctx):
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
await ctx.send("You are not in a voice channel.")
Expected Results
After the "Voice handshake complete" message, the connection should fully establish, and the log should show "Voice connection complete."
Actual Results
The connection stops after the "Voice handshake complete" stage.
It does not proceed to "Voice connection complete."
After waiting, it times out with "Timed out connecting to voice."
System Information
- Linux Ubuntu 24.04 LTS
- Python 3.12.3
- discord.py-self latest git install
Checklist
- I have confirmed I am using unmodified discord.py-self and not the upstream discord.py.
- I am using a user token (and it isn't visible in the code).
- I have searched the open issues for duplicates.
- I have searched closed issues for resolved duplicates.
- I have confirmed the development version doesn't resolve the issue.
- I have shared the entire traceback.
Additional Information
2025-04-27 16:26:09 INFO discord.voice_state Connecting to voice...
2025-04-27 16:26:09 INFO discord.voice_state Starting voice handshake (connection attempt 1)...
2025-04-27 16:26:10 INFO discord.voice_state Voice handshake complete. Endpoint found: hongkong11135.discord.media.
2025-04-27 16:26:39 INFO discord.voice_state Timed out connecting to voice.
2025-04-27 16:26:39 INFO discord.voice_state The voice handshake is being terminated for channel ID 1306943182331842583 (guild ID 1204973330449567774).
2025-04-27 16:26:39 INFO discord.voice_state The voice handshake is being terminated for channel ID 1306943182331842583 (guild ID 1204973330449567774).
2025-04-27 16:26:40 INFO discord.voice_state Connecting to voice...
2025-04-27 16:26:40 INFO discord.voice_state Starting voice handshake (connection attempt 1)...
2025-04-27 16:26:40 INFO discord.voice_state Voice handshake complete. Endpoint found: hongkong11135.discord.media.
2025-04-27 16:27:25 ERROR discord.client Ignoring exception in on_voice_state_update
Traceback (most recent call last):
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/requests/websockets.py", line 621, in recv
chunk, frame = await self.recv_fragment(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/requests/websockets.py", line 577, in recv_fragment
chunk, frame = await asyncio.wait_for(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/curl.py", line 426, in ws_recv
self._check_error(ret, "WS_RECV")
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/curl.py", line 150, in _check_error
raise error
curl_cffi.curl.CurlError: Failed to WS_RECV, curl: (81) . See https://curl.se/libcurl/c/libcurl-errors.html first for more details.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/discord/voice_state.py", line 424, in _inner_connect
await self._handshake_websocket()
File "/usr/local/lib/python3.12/dist-packages/discord/voice_state.py", line 611, in _handshake_websocket
await self.ws.poll_event()
File "/usr/local/lib/python3.12/dist-packages/discord/gateway.py", line 1136, in poll_event
msg, flags = await asyncio.wait_for(self.ws.recv(), timeout=self._max_heartbeat_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/requests/websockets.py", line 628, in recv
await aselect(sock_fd, loop=loop, timeout=timeout)
File "/usr/local/lib/python3.12/dist-packages/curl_cffi/requests/websockets.py", line 89, in aselect
await asyncio.wait_for(future, timeout)
File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/dist-packages/discord/client.py", line 689, in _run_event
await coro(*args, **kwargs)
File "/root/ren/moy.py", line 253, in on_voice_state_update
await target_channel.connect(self_mute=True)
File "/usr/local/lib/python3.12/dist-packages/discord/abc.py", line 2833, in connect
await voice.connect(timeout=timeout, reconnect=reconnect, self_deaf=self_deaf, self_mute=self_mute)
File "/usr/local/lib/python3.12/dist-packages/discord/voice_client.py", line 311, in connect
await self._connection.connect(
File "/usr/local/lib/python3.12/dist-packages/discord/voice_state.py", line 389, in connect
await self._connector
File "/usr/local/lib/python3.12/dist-packages/discord/voice_state.py", line 393, in _wrap_connect
await self._connect(*args)
File "/usr/local/lib/python3.12/dist-packages/discord/voice_state.py", line 442, in _connect
await asyncio.wait_for(
File "/usr/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
async with timeouts.timeout(timeout):
File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError