Closed febkosq8 closed 1 year ago
I have this issue too, on Ubuntu 22 like febkosq8, the bot just connects and skip to the song end, emitting the event
Update : Tried playing a local file as shown in LINK and that seems to work fine both on Heroku/Windows.
I have the same issue in which bot can't play music on Heroku when using discord-player v6
I can confirm this issue, tried on :
Arch 5.15.79.1-microsoft-standard-WSL2
node:19.4.0-alpine3.16
Local file was also working
Docker image node:19.7.0-bullseye-slim
is working
Are you guys by chance using es modules? 🤔
Are you guys by chance using es modules? 🤔
Personally no.
I do
I do
Same issue on CentOS Stream release 8
.
It worked before on discord-player v5 (i used Androz2091 discord-music-bot directly, now I'm upgrading it to v6)
running linux on kernel 6.1.1-arch1-1
, discord-player 6.1.0
bot won't play any music for me either
So it seems it's more of a linux problem than an Ubuntu specific issue.
But not all Linux distros. debian on wsl worked fine. So does Ubuntu 20.04.
i can't reproduce this on macOS 12.6.3 (UNIX based OS) so this is a Linux problem
Could it be node-related? I'm still on node 16.
Im happy to help troubleshooting on my system.
Could it be node-related? I'm still on node 16.
Im happy to help troubleshooting on my system.
Nop, working on docker image node:19.7.0-bullseye-slim
Imo its more of a problem with recent versions of Linux, as older versions seem to work fine so far
That's what i meant. Maybe it's an issue with older versions of node. I'm on node 16 so...
Sent from Ninehttp://www.9folders.com/
Da: Mylloon @.***> Inviato: domenica 12 marzo 2023 16:21 A: Androz2091/discord-player Cc: Alessandro Losi; Comment Oggetto: Re: [Androz2091/discord-player] Bot won't play any songs if running on some Linux distros (Issue #1639)
Could it be node-related? I'm still on node 16.
Im happy to help troubleshooting on my system.
Nop, working on docker image node:19.7.0-bullseye-slim
— Reply to this email directly, view it on GitHubhttps://github.com/Androz2091/discord-player/issues/1639#issuecomment-1465226424, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACG7N2FCNXP7VG35AM2Z73W3XSXJANCNFSM6AAAAAAVPQEYXM. You are receiving this because you commented.Message ID: @.***>
For me it wasn't working for the alpine version of node 19 (node:19.4.0-alpine3.16
) so I don't think it's node related, but maybe, Idk
I also had this problem on Ubuntu 22, I got it to work by running the bot in a Docker image, specifically ghcr.io/parkervcp/yolks:nodejs_18
for the Pterodactyl Panel, which appears to be based on the node:18-bullseye-slim
image
Have any tempory fixes been found?
Edit: Trying above Fix, Didn't Notice it 0_0
It didn't work for me in the node:18-alpine image. So I used node:19.7.0-bullseye-slim as @Mylloon suggested above. It works for me now without the issue. I use railway.app to host the project. Since the node version is different from the image I used, I think it is because of the node version installed in the distro that causing the problem. I don't know if that is the case just a hunch.
It's not node related. On centos stream i've tried node 16, 18 and 19 (all with the respective latest minors) and nothing changed.
Sent from Ninehttp://www.9folders.com/
Da: Karthik Raj @.***> Inviato: sabato 18 marzo 2023 06:36 A: Androz2091/discord-player Cc: Alessandro Losi; Comment Oggetto: Re: [Androz2091/discord-player] Bot won't play any songs if running on some Linux distros (Issue #1639)
It didn't work for me in the node:18-alpine image. So I used node:19.7.0-bullseye-slim as @Mylloonhttps://github.com/Mylloon suggested above. It works for me now without the issue. I use railway.app to host the project. Since the node version is different from the image I used, I think it is because of the node version installed in the distro that causing the problem. I don't know if that is the case just a hunch.
— Reply to this email directly, view it on GitHubhttps://github.com/Androz2091/discord-player/issues/1639#issuecomment-1474730002, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACG7N7GMBG5QZNXEA4DWQLW4VCXJANCNFSM6AAAAAAVPQEYXM. You are receiving this because you commented.Message ID: @.***>
Same issue here on ubuntu 22.04. Any news on this?
I did not realize that this was an issue until I saw messages in Zerio's Discord channel. The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:
player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(``Added to the queue ${track.title}``) } else { queue.metadata.channel.send(``Track **${track.title}** queued``); } });
player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(``Playlist added ${track.title}``) } else { queue.metadata.channel.send(``Playlist starts from title: ${track.title}``); } });
I did not realize that this was an issue until I saw messages in Zerio's Discord channel. The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:
player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(
Added to the queue ${track.title}) } else { queue.metadata.channel.send(
Track ${track.title} queued); } });
player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(
Playlist added ${track.title}) } else { queue.metadata.channel.send(
Playlist starts from title: ${track.title}); } });
I didn't tried this fix, but how that would help?
I did not realize that this was an issue until I saw messages in Zerio's Discord channel. The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:
player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(
Added to the queue ${track.title}) } else { queue.metadata.channel.send(
Track ${track.title} queued); } });
player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(
Playlist added ${track.title}) } else { queue.metadata.channel.send(
Playlist starts from title: ${track.title}); } });
I didn't tried this fix, but how that would help?
When a player starts to play, it checks the queue and notifies that it is empty, and skips to emptyQueue event. If you remove those audioTrack(s)Add events, the code works fine. So, the solution actually uses the event path: connection -> playerStart -> audioTrackAdd/audioTracksAdd -> emptyQueue. My solution forces the event path to if condition. That it doesn't reach emptyQueue while it is playing.
So since this code only writes messages, if i remove the event handler altogether, the issue gets solved anyway?
Also I don't get how this fix should be platform dependent (not needed on windows, but needed on linux)
When a player starts to play, it checks the queue and notifies that it is empty, and skips to emptyQueue event. If you remove those audioTrack(s)Add events, the code works fine. So, the solution actually uses the event path: connection -> playerStart -> audioTrackAdd/audioTracksAdd -> emptyQueue. My solution forces the event path to if condition. That it doesn't reach emptyQueue while it is playing.
I tested out that suggestion, as expected doesn't help. Also I am sure that the playerEvents don't work that way.
I recently moved my bot to a Digital Ocean droplet using Ubuntu 22.04 and I'm getting the same debug log as OP.
I set up a remote debugger and found it's breaking in the 'youtube-sr' package due to a rejected promise when trying to fetch.
youtube-sr/dist/mod.js line 532 inside getHTML.
Exception has occurred: TypeError [ERR_INVALID_STATE]: Invalid state: Writer has been released at new NodeError (node:internal/errors:399:5) at lazyWritableReleasedError (node:internal/webstreams/writablestream:95:19) at writableStreamDefaultWriterRelease (node:internal/webstreams/writablestream:1004:30) at finalize (node:internal/webstreams/readablestream:1289:5) at node:internal/webstreams/readablestream:1322:15 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I'm not sure where to go with this though. Is this useful?
Edit: I just noticed @skdhg is the owner of the 'youtube-sr' package and he marked this thread as "under discussion". Just wanted to ping him so he see's this.
Edit 2: Sorry all, I think this was a red herring. 'youtube-sr' will try to use a global fetch if it exists and node v18+ has a built in global.fetch which was causing this "uncaught exception" in the debugger. So, as a test, in my code I deleted global.fetch before trying to play music which caused 'youtube-sr' to use node-fetch instead but it's still not playing music. I'm just not getting a break point now. My debug log still looks the same as OP.
Debug emitted: state change: from {"status":"buffering","resource":true,"stepTimeout":false} to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false} Debug emitted: [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":395145}} Debug emitted: [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":395145}} Debug emitted: Track {"title":"JAY-Z - Anything","isTransitionMode":false} was marked as finished Debug emitted: Adding track to history and emitting finish event since transition mode is disabled... Debug emitted: No more tracks left in the queue to play and repeat mode is off, initiating #emitEnd() Debug emitted: state change: from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false} to {"status":"idle","resource":false,"stepTimeout":false}
The status changes to playing and then is marked as finished with a playback duration of 120 ms. Back to the drawing board...
if it was youtube-sr problem, it would not return search result in first place. The issue occurs at audio player, where stream just ends after 120ms playback. This could possibly be ffmpeg issue? I don't have time to look into it at the moment as im busy these days.
I'm also going to do some testing this week. I agree with skdhg on this one. It's very possible it's a ffmpeg issue due to it having issues with the stream data. I'll update this thread if I discover anything valuable for sharing.
Sorry, I been also buzy. I have a student group as trainers and we have developed a discord bot for taking a break and it based on a music bot. One of students uses Linux and last week a fix I mentioned earlier did worked but not on this week. Another thing what I noticed yesterday (Windows user) was that one of the students had removed queue from play.js and they is still able to add /play music1, /play music2, /play music3, etc. (as there would be a queue) and player plays music2 after it has finished music1. Earlier at list in @discord/voice and distube adding a new /play music command caused (without queue handling) that player switches to a new song which just added.
We have used singleton and useMasterPlayer() in our project and code based on strictly discord-player 6.0, discord v.14, and node.js 18.15.
I will try to investigate this issue today and let you guys know 👍
The problem seems to be static binaries of ffmpeg, pulled from johnvansickle.com/ffmpeg
. Please install ffmpeg via apt
or other package managers and avoid static binaries.
The bot seems to be working fine on WSL - Ubuntu 22.04 under following circumstances:
sudo apt update
& sudo apt install ffmpeg
)This issue occurs upon using ffmpeg-static
instead of the version used in update 1:
FFmpeg Static
ffmpeg version 5.0.1-static https://johnvansickle.com/ffmpeg/
Debug Log
[DEBUG] Player triggered for Track {"title":"2 Phút Hơn - KAIZ Remix","reason":"normal"}
[DEBUG] state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
[DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":746032}}
[DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":746032}}
[DEBUG] Track {"title":"2 Phút Hơn - KAIZ Remix","isTransitionMode":false} was marked as finished
[DEBUG] Adding track to history and emitting finish event since transition mode is disabled...
[DEBUG] No more tracks left in the queue to play and repeat mode is off, initiating #emitEnd()
[DEBUG] state change:
from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
This buildpack seems to be using johnvansickle.com/ffmpeg (the same one is used by ffmpeg-static
package) based on this line https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest/blob/25e435c249349b5d201f346449fcdf26bce1a065/bin/compile#L34
The problem seems to be static binaries of ffmpeg, pulled from johnvansickle.com/ffmpeg
. Please install ffmpeg via apt
or other package managers and avoid static binaries.
This fixes my issue. Thanks for taking the time to look!
I removed 'ffmpeg-static' from my project yesterday but didn't realize it was still in my node_modules folder (I don't do much js dev). Once I cleared it out, it started to work. I can also confirm it works with ffmpeg 6.0 but I can't recommend anyone install it since it may break something else for you.
Removed ffmpeg and ffmpeg-static and installed ffmpeg through
sudo apt install ffmpeg
and cleared npm cache as well and then tried still track ending immediately.Ubuntu 22.10 btw
What is the ffmpeg version as per player.scanDeps()
?
Nvm i completely removed bot files, hosted again and it worked
I guess even after npm cache clean --force
cache was not cleared for some reason
Solved on centos by removing ffmpeg-static, removing package-lock.json and reinstalled all packages. Ffmpeg installed on system is version 5.x
from discord-player v6.3x, the package ships with its own ffmpeg implementation which gives less priority to static binaries so it should work better than how it used to. You can also set FFMPEG_PATH
environment variable to load ffmpeg from custom path if needed.
I'm sorry, I've done everything here without it working.
My buildbacks are as follow :
Here is the interesting part of my package.json
{
"engines": {
"node": "18.14.2",
"npm": "9.6.7"
},
"dependencies": {
"@discord-player/extractor": "^4.4.0",
"@discordjs/opus": "^0.8.0",
"discord-player": "^6.6.1",
"discord.js": "^14.11.0",
"ms": "^3.0.0-canary.1",
"play-dl": "^1.9.6"
}
}
I tried npm install
then I tried yarn
, both before and after removing lock files and node_modules
folder.
I tried reseting the Heroku repo by cleaning everything inside and reinstalling from scratch.
I don't think I can sudo snap install ffmpeg
inside of Heroku since first, it's bash, and I don't think I have the rights to do so. Any advice?
@Loadren can you try running your bot inside docker container? Pretty sure heroku supports docker
@skdhg I've never used Docker, but I'll try it and give you feedback.
@skdhg Docker worked! Thanks!
Im having this same problem, i already tried using docker images but nothing, tried 19.7.0-bullseye-slim , 20, 16, and it doesnt work, also it wont work on my main machine which is debian 12.
Any ideas?
Stream extraction was successful for Track { title: Como Camarón, url: https://open.spotify.com/track/1VB4sadHjFcFklHcZuoROi } (Extractor: com.discord-player.spotifyextractor) Waiting for willPlayTrack event to resolve... skipFFmpeg is set to true and stream is demuxable, creating stream with type pcm Preparing final stream config: { "dispatcherConfig": { "disableBiquad": false, "disableEqualizer": false, "disableVolume": false, "disableFilters": false, "disableResampler": true, "sampleRate": 48000, "eq": [], "defaultFilters": [], "volume": 100, "data": { "id": "1259464874015068161", "title": "Como Camarón", "description": "Como Camarón by Estopa", "author": "Estopa", "url": "https://open.spotify.com/track/1VB4sadHjFcFklHcZuoROi", "thumbnail": "https://i.scdn.co/image/ab67616d0000b2731a311570340a4f6530da158b", "duration": "03:22", "durationMS": 202000, "views": 0, "requestedBy": null, "playlist": null }, "type": "raw", "skipFFmpeg": true }, "playerConfig": { "queue": false, "transitionMode": false, "seek": 0 } } Initiating DSP filters pipeline... Executing onAfterCreateStream hook... Preparing AudioResource... Initializing audio player... state change: from {"status":"idle","resource":false,"stepTimeout":false} to {"status":"buffering","resource":true,"stepTimeout":false} Dispatching audio... Player triggered for Track {"title":"Como Camarón","reason":"normal"} state change: from {"status":"buffering","resource":true,"stepTimeout":false} to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false} [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":821694}} [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":821694}} Track {"title":"Como Camarón","isTransitionMode":false} was marked as finished Adding track to history and emitting finish event since transition mode is disabled... No more tracks left in the queue to play and repeat mode is off, initiating #emitEnd() state change: from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false} to {"status":"idle","resource":false,"stepTimeout":false}
I personally use node:22.2.0-bullseye-slim
@Klairm Here is my current Dockerfile
FROM node:18.14.2-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN apk add --no-cache make gcc g++ python3 && \
npm install && \
apk del make gcc g++ python3
RUN apk add --no-cache ffmpeg
COPY . .
CMD ["node", "./index.js"]
Try using @distube/ytdl-core if you use YouTube. Sometimes, you may have to switch to a different library (like play-dl) to fix this problem.
@Klairm Here is my current Dockerfile
FROM node:18.14.2-alpine WORKDIR /usr/src/app COPY package*.json ./ RUN apk add --no-cache make gcc g++ python3 && \ npm install && \ apk del make gcc g++ python3 RUN apk add --no-cache ffmpeg COPY . . CMD ["node", "./index.js"]
Try using @distube/ytdl-core if you use YouTube. Sometimes, you may have to switch to a different library (like play-dl) to fix this problem.
After moving to ytdl-core the issue was fixed, thanks
Im having this same problem, i already tried using docker images but nothing, tried 19.7.0-bullseye-slim , 20, 16, and it doesnt work, also it wont work on my main machine which is debian 12.
Any ideas?
Sounds like your most likely problem is with the streaming library. Go one by one through the packages mentioned in https://discord-player.js.org/guide/welcome/welcome
$ npm install --save youtube-ext
# or
$ npm install --save play-dl
# or
$ npm install --save @distube/ytdl-core
# or
$ npm install --save yt-stream
# or
$ npm install --save ytdl-core
If this solves your problem, then keep note than that particular library might stop working one day and you might have to go thro the list again from top. Chances are you will find something that works.
Adding @febkosq8 statement, it is also recommended to keep your YouTube libraries to the latest as YouTube regularly updates their applications.
Describe the bug When I run the bot on my local Windows 11 machine, everything works fine.
But when the bot runs on Ubuntu 22, the bot will skip playing and directly go to the finish state. I host my bot in Heroku (running on Ubuntu 22.04 stack). This issue doesn't exist in Ubuntu 20 (As a workaround downgrading heroku stack to 20 fixes this issue).
Current list of affected Linux distro :
index.js
play.js
Attaching debug event to the player below :
Ubuntu 22.04
Result when play command is used: The bot joins the VC and leaves in a second. It also triggers the following events in order : audioTrackAdd > playerStart > emptyQueue > disconnect.
Windows 11 22H2
Result when play command is used: The bot joins the VC and starts to play the requested music. It also triggers the following events in order : audioTrackAdd > playerStart.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Screenshots
Please complete the following information:
Additional context
The only changing factor I know is the ffmpeg build being used but Heroku same buildpack on stack 20 works fine.
On Windows : https://www.gyan.dev/ffmpeg/builds/
On Heroku (Buildpack) : https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
On Ubuntu 22.04 :
sudo snap install ffmpeg