title: Discord.js Voice Connection Timeout
body: <p>I am currently struggling with a problem of my discord.js bot that plays a music stream via an url. Everything works fine, but after about 12h all players disconnect and I get the following error message: <code>[VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.</code></p>
  <p>This is my code to join/leave a channel:</p>
  <pre><code>function join(voiceChannel, volume = 20) {
      return new Promise((resolve, reject) =&gt; {
          voiceChannel.join().then(vc =&gt; {
              vc.voice.setSelfDeaf(true);
  
              const dispatcher = vc.play(streamURL);
              dispatcher.once('start', () =&gt; {
                  dispatcher.setBitrate(64);
                  dispatcher.setVolumeLogarithmic(volume / 100);
  
                  setTimeout(() =&gt; {
                      if (voiceChannel.members.filter(m =&gt; !m.user.bot).size === 0) dispatcher.pause(true);
                  }, 1500);
  
                  resolve();
              });
  
              // Tried to reconnect on error but does not seem to work
              dispatcher.on('error', () =&gt; {
                  leave(voiceChannel.guild);
                  setTimeout(() =&gt; join(voiceChannel, volume), 5000);
              });
          }).catch(err =&gt; reject(err));
      });
  }
  
  function leave(guild) {
      guild.me?.voice?.connection?.disconnect();
  }
  </code></pre>
  <p>I also have this event set up to pause the stream if nobody is listening:</p>
  <pre><code>client.on('voiceStateUpdate', (oldState, newState) =&gt; {
      const state = oldState || newState;
      if (state?.member.user.bot) return;
  
      const guild = state?.guild;
      if (!guild?.me?.voice?.connection) return;
      if (newState.channel === oldState.channel) return;
  
      Guild.findOne({guildId: guild.id}, (err, dbGuild) =&gt; {
          if (err || !dbGuild) return;
  
          const channel = guild.channels.cache.get(dbGuild.musicChannelId);
          if (!channel || !guild.me.voice.connection.dispatcher) return;
  
          const dispatcher = guild.me.voice.connection.dispatcher;
          if (channel.members.filter(m =&gt; !m.user.bot).size &gt; 0 &amp;&amp; dispatcher.paused) {
              dispatcher.resume();
              return;
          }
  
          if (!dispatcher.paused &amp;&amp; channel.members.filter(m =&gt; !m.user.bot).size === 0) {
              dispatcher.pause(true);
          }
      });
  });
  </code></pre>
  <p>Maybe somebody can help me with this. I don't know how to fix this error.</p>