You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the past few days I have started receiving an exception whenever the bot has connected to a voice channel causing the voice (playback) to abruptly cut out.
The exception is/was: interactions.client.errors.VoiceWebSocketClosed: The Websocket closed with code: 4020 - Unknown Error
The root cause of this problem was identified on the Discord Developer server here (for more info, etc.).
Apparently there has been a silent change in the Discord backend because it no longer accepts a string or a float for the d parameter of the payload in case of a heartbeat event.
Simply changing the way the random sequence is generated from random.uniform(0.0, 1.0) to random.getrandbits(64) in interactions/api/voice/voice_gateway.py fixes the issue.
Fixed version:
Connect to a voice channel. As soon as a heartbeat is sent the ws will close with code 4020.
Expected Results
Working voice functionality.
Minimal Reproducible Code
No response
Traceback
Task exception was never retrieved
future: <Task finished name='Task-88' coro=<ActiveVoiceState._ws_connect() done, defined at U:\src\sbdev\.venv\Lib\site-packages\interactions\models\internal\active_voice_state.py:105> exception=VoiceWebSocketClosed('The Websocket closed with code: 4020 - Unknown Error')>
Traceback (most recent call last):
File "U:\src\sbdev\.venv\Lib\site-packages\interactions\models\internal\active_voice_state.py", line 109, in _ws_connect
await self.ws.run()
File "U:\src\sbdev\.venv\Lib\site-packages\interactions\api\voice\voice_gateway.py", line 85, in run
msg = await receiving
^^^^^^^^^^^^^^^
File "U:\src\sbdev\.venv\Lib\site-packages\interactions\api\voice\voice_gateway.py", line 121, in receive
raise VoiceWebSocketClosed(resp.data)
interactions.client.errors.VoiceWebSocketClosed: The Websocket closed with code: 4020 - Unknown Error
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.
I have attempted to debug this myself, and I believe this issue is with the library
Additional Information
No response
The text was updated successfully, but these errors were encountered:
SirTurlock
changed the title
[BUG] Incorrect heartbeat event causes VoiceGateway websocket to be closed with code 4020
[BUG] Incorrect heartbeat event payload causes VoiceGateway websocket to be closed with code 4020
Aug 5, 2024
…t is sent
Fixesinteractions-py#1726
VoiceGateway no longer accepts a string or a float in the heartbeat nonce and instead immediately disconnects the client with code 4020.
Fixed send_heartbeat to use an uint64 instead of a float for the nonce.
Library Version
5.13.1
Describe the Bug
In the past few days I have started receiving an exception whenever the bot has connected to a voice channel causing the voice (playback) to abruptly cut out.
The exception is/was:
interactions.client.errors.VoiceWebSocketClosed: The Websocket closed with code: 4020 - Unknown Error
The root cause of this problem was identified on the Discord Developer server here (for more info, etc.).
Apparently there has been a silent change in the Discord backend because it no longer accepts a string or a float for the d parameter of the payload in case of a heartbeat event.
Simply changing the way the random sequence is generated from
random.uniform(0.0, 1.0)
torandom.getrandbits(64)
ininteractions/api/voice/voice_gateway.py
fixes the issue.Fixed version:
Steps to Reproduce
Connect to a voice channel. As soon as a heartbeat is sent the ws will close with code 4020.
Expected Results
Working voice functionality.
Minimal Reproducible Code
No response
Traceback
Checklist
Additional Information
No response
The text was updated successfully, but these errors were encountered: