Skip to content
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

Track stops playing after 30-60 seconds #1630

Closed
Nico-Mayer opened this issue Mar 2, 2023 · 4 comments
Closed

Track stops playing after 30-60 seconds #1630

Nico-Mayer opened this issue Mar 2, 2023 · 4 comments
Labels
discord.js bug t:voice Related to voice system

Comments

@Nico-Mayer
Copy link

Describe the bug
After the bot joins the VC it starts playing the selected song, but after 30-60 the track stops.
Bot stays in VC for quite some time after that.
No logs are present in Node console.
Same bug is mentioned here Issue

To Reproduce
Steps to reproduce the behavior:

  1. Play a song via slash command
  2. Wait until song stops playing.

Expected behavior
Bot should play the whole song and then leve the VC.

Screenshots

Please complete the following information:

  • Node Version: 19.7.0 & 18.14.2
  • Discord Player Version: 5.4.0
  • Discord.js Version: 14.7.1

Additional context

@Nico-Mayer Nico-Mayer added the bug Something isn't working label Mar 2, 2023
@Crocross
Copy link
Contributor

Crocross commented Mar 2, 2023

@Nico-Mayer , the issue is with a change from discord and discordjs/voice. It's not really a discord-player issue. There are two temporary fixes right now that you can use in the meantime that are in the discord thanks to @skdhg :

import { VoiceConnectionStatus } from '@discordjs/voice';
// or const { VoiceConnectionStatus } = require('@discordjs/voice');

// v6
player.events.on('connection', (queue) => {
    queue.dispatcher.voiceConnection.on('stateChange', (oldState, newState) => {
        if (oldState.status === VoiceConnectionStatus.Ready && newState.status === VoiceConnectionStatus.Connecting) {
            queue.dispatcher.voiceConnection.configureNetworking();
        }
    });
});

// v5
player.on('connectionCreate', (queue) => {
    queue.connection.voiceConnection.on('stateChange', (oldState, newState) => {
        if (oldState.status === VoiceConnectionStatus.Ready && newState.status === VoiceConnectionStatus.Connecting) {
            queue.connection.voiceConnection.configureNetworking();
        }
    })
});

@twlite twlite added the t:voice Related to voice system label Mar 3, 2023
@twlite
Copy link
Collaborator

twlite commented Mar 3, 2023

This is the new solution as per discordjs/discord.js#9185 (comment)

// v6
player.events.on('connection', (queue) => {
  queue.dispatcher.voiceConnection.on('stateChange', (oldState, newState) => {
    const oldNetworking = Reflect.get(oldState, 'networking');
    const newNetworking = Reflect.get(newState, 'networking');

    const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
      const newUdp = Reflect.get(newNetworkState, 'udp');
      clearInterval(newUdp?.keepAliveInterval);
    }

    oldNetworking?.off('stateChange', networkStateChangeHandler);
    newNetworking?.on('stateChange', networkStateChangeHandler);
  });
});

// v5
player.on('connectionCreate', (queue) => {
    queue.connection.voiceConnection.on('stateChange', (oldState, newState) => {
      const oldNetworking = Reflect.get(oldState, 'networking');
      const newNetworking = Reflect.get(newState, 'networking');

      const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
        const newUdp = Reflect.get(newNetworkState, 'udp');
        clearInterval(newUdp?.keepAliveInterval);
      }

      oldNetworking?.off('stateChange', networkStateChangeHandler);
      newNetworking?.on('stateChange', networkStateChangeHandler);
    });
});

@zoltan-lima
Copy link

Is anyone else after implementing this fix running into the issue that the player only plays tracks for 2m 30s and then stops and queues the next track? Is there a fix similair to above for it?

TannerGabriel pushed a commit to TannerGabriel/discord-bot that referenced this issue Mar 3, 2023
Fix for player autopausing after quitting after 30-60s.

Androz2091/discord-player#1630 (comment)
@twlite
Copy link
Collaborator

twlite commented Mar 4, 2023

Note to newcomers

If you just installed discord-player, there's a chance that you have v6.0.0 installed. If yes, you can ignore this issue as discord-player v6.0.0 comes with this patch. v6.0.0 users can disable default patch by setting DP_NO_KEEPALIVE_PATCH=true, although this patch only gets applied if @discordjs/voice version is less than or equal to 0.14.0

MoeSW added a commit to MoeSW/MUPPETBOT that referenced this issue Mar 6, 2023
* fix: Discord opus dependency issue

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Fix activityType (TannerGabriel#199)

* Fix activityType

* Revert "Fix activityType"

This reverts commit 58455f6.

* Fix activityType and status

* Switch Dockerfile to distroless base image (TannerGabriel#209)

* Switch Dockerfile to distroless image

* Docker: Compress ffmpeg with upx

* feat: add docker build github action (TannerGabriel#208)

* feat: add docker build github action

should use github.actor

prepare for upstream pr

* update readme

* Update README.md

* fix: Docker build action (TannerGabriel#211)

* fix: Docker build action repo name

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Add workflow dispatch to docker build action

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

---------

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>

* Update index.js (TannerGabriel#213)

Fix for player autopausing after quitting after 30-60s.

Androz2091/discord-player#1630 (comment)

---------

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>
Co-authored-by: TannerGabriel <gabrieltanner.code@gmail.com>
Co-authored-by: Bygrilinho <20670349+Bygrilinho@users.noreply.github.com>
Co-authored-by: Florentin Schäfer <florentin.schaefer@gmail.com>
Co-authored-by: Fredrick Myrvoll <fredrickmyrvoll@gmail.com>
Co-authored-by: smclean117 <90870055+smclean117@users.noreply.github.com>
@twlite twlite closed this as completed Mar 15, 2023
famousdev0207 added a commit to famousdev0207/Discord-bot that referenced this issue May 17, 2023
Fix for player autopausing after quitting after 30-60s.

Androz2091/discord-player#1630 (comment)
@twlite twlite unpinned this issue Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discord.js bug t:voice Related to voice system
Projects
None yet
Development

No branches or pull requests

4 participants