discord.js: Voice: connection timeout after 15 seconds.

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:

  • discord.js version: 12…0.0-dev lastest commit
  • Node.js version: 10.14.1
  • Operating system: Ubuntu 18.04
  • Priority this issue should have – please be realistic and elaborate if possible: Medium, as I cannot serve streams at all.
  • [ x] I have also tested the issue on latest master, commit hash:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (2 by maintainers)

Commits related to this issue

Most upvoted comments

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.

According to my experience with discord.js it happens only sometimes and goes away after a while. At this moment issue is not persisting. I did not change any code.

I’ve seen this said a few times, however for myself the code never worked. My bot has always refused to join a Voice Channel, and I’ve done everything. Tried on different machines, different code, and waited weeks now. No change, and no solid solution either 😕

If there is a solid solution then this issue thread wouldn’t be open. This error forced me to take a break from discord bots. When I came back, the issue was gone and no longer persists for me. I hope that solution would be found soon.

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

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.

I have the exact same issue as the above code, anyone find a fix for this?

Same, but for me it works on most of the servers, but on some it doesn’t.

I actually found a solution that fixed the error completely for my circumstance. In my index.js file I have a list of gateway intents, and it was missing GUILD_VOICE_STATES. Once I added it in, the bot worked flawlessly for it’s intended purpose.

Took me some time to realise this, and not too sure how I missed it the first few times over.