-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Can't play audio because of WS_NOT_OPEN #5443
Comments
Hi there, We're working on a new implementation of Discord's Voice API that has better playback quality and is more reliable than what we currently support in Discord.js v12 - check it out at https://github.com/discordjs/voice! The new library solves many of the issues that users are facing, and as part of this, we're dropping built-in support for voice in our next major release. We have a PR (#5402) that adds native support for our new voice library - once this PR is merged, this issue will be closed. You can still use our new voice library before that PR lands - just take a look at our music bot example to see how to get started upgrading your voice code. By using the boilerplate music player in the example, you can make it even easier to upgrade your code. Note that the PR above only reduces some of the boilerplate code you'd otherwise have to write - you do not have to wait for the PR to be merged to start using the new voice library. If you have any questions about this, feel free to:
|
Please describe the problem you are having in as much detail as possible:
Can't play audio when a bot stays in a voice channel for a long time, days or weeks, and the error can't be handled without the debug event. Here is the error log.
Once the error happens, it always happens when a bot plays audio. The connection is never playable.
I found the following logs before the
WS_NOT_OPEN
error.In short, a
VoiceConnection
has no WebSocket connection after it hits the retry limit, then never playable, and we have no way to handle it. That's the problem.Include a reproducible code sample here, if possible:
Note: Prepare a short audio file as
sample.mp3
It should reproduce the situation.
VOICE_CONNECTION_ATTEMPTS_EXCEEDED
happens at 5, after that,WS_NOT_OPEN
always happens, and audio doesn't stream after 10 or so because of the heartbeat failure.You might think the situation is very rare but I'd say it's not. My guild members are always in a voice channel, literally 24/7, then sometimes my bot encounters the retry limit, even my server has a good network. To leave and rejoin would simply fix it, but I assume that Discord.js itself should have a workaround.
Here are my proposals.
WS_NOT_OPEN
failed
event fromStreamDispatcher
dispatcher.on('failed', /* leave and rejoin or something */)
WS_NOT_OPEN
doesn't only happen after the retry limit but also happen while retrying because there is no connection betweenclose
andconnect
failed
event should happen after the heartbeat deadretryLimit
event fromVoiceConnection
and leave from a voice channel automatically when it hits the retry limitconnection.on('retryLimit', /* rejoin or something */)
failed
event onStreamDispatcher
, nor need to think about the heartbeatdisconnect
event (the next proposal might solve this)connection.on('disconnect', error => { if (error) /* rejoin or something */ })
error === undefined
means that it disconnected normally (same as the current version)error !== undefined
means that something went wrong and automatically disconnected by Discord.js itselfdisconnect
event interface that affects almost nothing to the current versionVoiceConnection
with no WebSocket connection is completely useless, there's no reason to hold, then we should've disconnected it in the first placeVOICE_CONNECTION_ATTEMPTS_EXCEEDED
knt2nd/knt2-dbot#1 is my current workaround by the way. After this, the
WS_NOT_OPEN
error never happens at all.Further details:
Relevant client options:
The text was updated successfully, but these errors were encountered: