Please describe the problem you are having in as much detail as possible:
When attempting to play a YTDL stream in a voice channel, there seems to an issue with the connection timeout.
{ Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
0|mrFox | at VoiceConnection.authenticateFailed (/home/rich/Fox/node_modules/discord.js/src/client/voice/VoiceConnection.js:268:27)
0|mrFox | at connectTimeout.client.setTimeout (/home/rich/Fox/node_modules/discord.js/src/client/voice/VoiceConnection.js:297:18)
0|mrFox | at Timeout.setTimeout (/home/rich/Fox/node_modules/discord.js/src/client/BaseClient.js:81:7)
0|mrFox | at ontimeout (timers.js:436:11)
0|mrFox | at tryOnTimeout (timers.js:300:5)
0|mrFox | at listOnTimeout (timers.js:263:5)
0|mrFox | at Timer.processTimers (timers.js:223:10) [Symbol(code)]: 'VOICE_CONNECTION_TIMEOUT' }
I am not sure why this is happening, as music worked server weeks ago, with no code change, only an upgrade in discord.js version.
Include a reproducible code sample here, if possible:
const dispatcher: StreamDispatcher = serverQueue.connection.play(
ytdl(song.url, { filter: "audioonly" }),
{ bitrate: "auto" }
);
The bot can join, but will error here.
Further details:
I will try to work on this issue as a volunteer.
Gist with test bot code I used to try to reproduce the error (updated for discord.js v12)
I am unable to reproduce your error with above code. The bot joins selected voice channel and plays requested youtube link. Are you doing something differently? Is it maybe an issue with the server you're running your bot from?
I used wrong Discord.js version, didn't look closely enough. Will check on v12.
Also my testing enivronment is:
12 (master branch, latest commit)10.14.1I originally thought so. However, after trying many different servers, the
issue still persists.
On Wed, Dec 5, 2018, 3:36 AM Mateusz Makowski <[email protected]
wrote:
Gist with test bot code I used to try to reproduce the error
https://gist.github.com/makos/de827e410cc53ac0ad5ee5965c3b2c79I am unable to reproduce your error with above code. Are you doing
something differently? Is it maybe an issue with the server you're running
your bot from?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/discordjs/discord.js/issues/2979#issuecomment-444402496,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOjIfv2d5Y-3Dufg8g8Vi2qw0gOu1_vsks5u14VwgaJpZM4Y8_5n
.
Been getting this a lot the past couple days. Doesn't always happen, only about half the time for me.
On latest commit, node 10.14.1, Debian Stretch.
I would try running your bot with the DEBUG=* option, like so:
shell
DEBUG=* node bot.js
and posting the related output when it crashes again.
I'll give it a look out for when it happens next, but it's not a crash -- it's a promise rejection from VoiceChannel.join() with the error "Connection not established within 15 seconds." I'm pretty sure the call stack in the OP is the best output we'll get for this.
I also have this issue occasionally.
Ubuntu 18.04.1 LTS
Node.js: v10.15.0
Discord.js version: master branch
I made a small custom soundboard and it seems like that it happens if no one was active in voice for a few hours. After a few tries / restarting the bot it fixes itself at some point. I know, not the best description to reproduce all of this, but I try to give more information if this issue persist.
EDIT: Switching voice regions kinda seems to fix the issue for some time, until it just doesn't work anymore.
Could you update to the latest commit (https://github.com/discordjs/discord.js/commit/aab3523fb5b60d21d20cbf2be01c32bdf21aa8ae) and try the following to produce some more debug information:
client.on('debug', console.log);
You should see output something like this:

If you could try this again and send me the full output from this log -- this will contain sensitive information so I'd recommend messaging me on Discord at hydrabolt#0001. However, you should still be ok to post the details here on GitHub if you remove your IP address from the logs and partially redact any IDs.
Ok, I've spoken to 2 users about the issue. After some restructuring of voice internals we were able to fix one of the issues (see commit 375706beac3219ae20885681112289bb2e0c6604) relating to event listeners being cleared that prevented Discord.js from connecting to the voice servers.
The other issue was that a user was hosting on Hetzner, which still seems to be blacklisted by Discord so we're unable to do anything about that ourselves - please bear this in mind if you're looking for servers to host your bot on!
After the work done, I'm pretty confident that the issue is fixed as much as it could be, if it still occurs it must be a network issue. If the issue does occur, please gather debug logs by listening to the debug event, e.g. client.on('debug', console.log) and then ask about it in the Discord.js server (make sure to redact any private information from the logs) or post an issue here. However, I'm closing this issue for now as if the issue still continues I'm pretty sure it's just a problem with your network.
I now have this issue. I host using Heroku but I test locally before pushing any commits. Doesn't seem to work on the Heroku server or locally. here's a log using debug:
```node bot.js
Authenticated using token: (my token which I will OBVIOUSLY not post. I'm pretty stupid but not that stupid)
Using gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connecting to wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connected to gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Identifying as a new session
[ws] [connection] Setting a heartbeat interval for 41250ms
[ws] [connection] Sending a heartbeat
READY 94eab04b4497662f2e881b7b6387f2b6
Hewwo
[ws] [connection] Heartbeat acknowledged, latency of 38ms
C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:107
throw up
^
Error: Error: Connection not established within 15 seconds.
at VoiceConnection.authenticateFailed (C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.jssrc\client\voice\VoiceConnection.js:268:27)
at C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.jssrc\client\voice\VoiceConnection.js:297:18
at Timeout.
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
```
Hi, I have the same error every time I try to join the voice channel. Error occurs in every server. Once I was able to play music but only once. I don't know why it worked that one time.
Error:
Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
Sometimes client is connecting to the voice and throwing error, sometimes does not even join.
And sometimes EVEN msg.member.voice.channel == null
I tried regenerating bot token and everything... please help
Discord.js v.12.3.1
Hi, I have the same error every time I try to join the voice channel. Error occurs in every server. Once I was able to play music but only once. I don't know why it worked that one time.
Error:Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.Sometimes client is connecting to the voice and throwing error, sometimes does not even join.
And sometimes EVENmsg.member.voice.channel == nullI tried regenerating bot token and everything... please help
Discord.js v.12.3.1
Here are logs after adding client.on('debug', console.debug); line:
[VOICE ({{here was guild id}}:2)]: Sending voice state update: {"guild_id":"{{here was guild id}}","channel_id":"{{here was channel id}}","self_mute":false,"self_deaf":false}
[VOICE] received voice server: {"t":"VOICE_SERVER_UPDATE","s":8,"op":0,"d":{"token":"{{here was token}}","guild_id":"{{here was guild id}}","endpoint":"eu-central5499.discord.media:80"}}
[VOICE] voiceServer guild: {{here was guild id}} token: {{here was token}} endpoint: eu-central5499.discord.media:80
[VOICE ({{here was guild id}}:2)]: Token "{{here was token}}" and endpoint "eu-central5499.discord.media:80"
[VOICE ({{here was guild id}}:2)]: Endpoint resolved as eu-central5499.discord.media
[VOICE ({{here was guild id}}:2)]: Authenticated with sessionID undefined
[VOICE ({{here was guild id}}:2)]: Authenticate failed - VOICE_CONNECTION_TIMEOUT
[ERROR] (node:3779) UnhandledPromiseRejectionWarning: Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
at VoiceConnection.authenticateFailed (/home/poprostumieciek/MieciekBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:296:27)
at /home/poprostumieciek/MieciekBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:324:61
at Timeout.<anonymous> (/home/poprostumieciek/MieciekBot/node_modules/discord.js/src/client/BaseClient.js:83:7)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
[ERROR] (node:3779) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[ERROR] (node:3779) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I replaced all informations that I am not comfortable sharing with.
Most helpful comment
I now have this issue. I host using Heroku but I test locally before pushing any commits. Doesn't seem to work on the Heroku server or locally. here's a log using debug:
```node bot.js
Authenticated using token: (my token which I will OBVIOUSLY not post. I'm pretty stupid but not that stupid)
Using gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connecting to wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connected to gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Identifying as a new session
[ws] [connection] Setting a heartbeat interval for 41250ms
[ws] [connection] Sending a heartbeat
READY 94eab04b4497662f2e881b7b6387f2b6
Hewwo
[ws] [connection] Heartbeat acknowledged, latency of 38ms
C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:107
throw up
^
Error: Error: Connection not established within 15 seconds. (C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.jssrc\client\Client.js:436:7)
at VoiceConnection.authenticateFailed (C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.jssrc\client\voice\VoiceConnection.js:268:27)
at C:\Users\IF64\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.jssrc\client\voice\VoiceConnection.js:297:18
at Timeout.
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
```