AudioResource not playing on Linux

I have a strange issue that I would assume is a dependency mismatch, however everything is in check. I play a URL audio source on my bot that will work on Windows but not on Linux; no errors occur, the audio resource just never plays.
let resource = createAudioResource(song.track.preview_url) //Something like p.scdn.co/mp3-preview/8129d5338c56d78f5712fc95d246198da5261854?cid=4c5368cfdc084da795955dd07534fa1e
audioplayer.play(resource)
console.log(song.track.preview_url)
console.log(resource.playbackDuration)
console.log(resource.read())
let resource = createAudioResource(song.track.preview_url) //Something like p.scdn.co/mp3-preview/8129d5338c56d78f5712fc95d246198da5261854?cid=4c5368cfdc084da795955dd07534fa1e
audioplayer.play(resource)
console.log(song.track.preview_url)
console.log(resource.playbackDuration)
console.log(resource.read())
playbackDuration is 0 and .read() returns null. No AudioPlayer error events (or errors in general) are emitted, all the dependencies project-wise are the same, and this resource does work on my own Windows PC. I've also double checked the resource is downloadable from my VPS. The url points to an mp3 file, so ffmpeg-static is being used. Below is the dependency list:
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: 4.0.4
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: 4.0.4
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
6 Replies
d.js toolkit
d.js toolkit17mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Spookadia
SpookadiaOP17mo ago
Discord.js 14.11.0 and Node 20.3.1 (20.2.0 on local pc) looking further into the audioplayer state, it goes immediate from Buffering -> Playing -> Idle. the audioresource is .readable() but has no duration, even though it's 30 seconds i am now realizing though that playbackDuration is 0 regardless of which PC, and if it's fully buffered or not
duck
duck17mo ago
@discordjs/voice does not stream from urls for you you'll need to fetch/request from the url first createAudioResource accepts a readable stream
Spookadia
SpookadiaOP17mo ago
i see, so windows is doing that automatically somehow?
duck
duck17mo ago
no, that's the issue nothing is currently streaming from the url, therefore your resource is empty
Spookadia
SpookadiaOP17mo ago
i getcha, i'll fetch it by itself first; now i'm just confused why my local one running on windows does work when just putting in a URL for the input doing this resolved my problem:
let stream = (await (await fetch(song.track.preview_url)).blob()).stream()
let resource = createAudioResource(stream)
let stream = (await (await fetch(song.track.preview_url)).blob()).stream()
let resource = createAudioResource(stream)
Want results from more Discord servers?
Add your server