Discord voice doesn't play remote audio on linux

I have a weird behavior where playing audio from an URL works on my windows PC, but doesn't on my linux server. Basically I'm trying to play audio from this url: https://cdn.communitydragon.org/15.4.1/champion/gnar/champ-select/sounds/choose After adding logs I realized that the audio player's state was changing from autopaused to playing and then from playing to idle almost instantly I tried downloading the audio file locally and them playing it and it works fine. I'm using Amazon Linux on my EC2 instance.
4 Replies
d.js toolkit
d.js toolkit2w ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Sam
SamOP2w ago
I'm using discord.js v14.16.1 with discord.js/voice v0.17.0 and discord.js/opus v0.9.0 I've created a test command here:
const resource = createAudioResource('https://cdn.communitydragon.org/15.4.1/champion/gnar/champ-select/sounds/choose');

const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.member.voice.channel.guild.id,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

const player = createAudioPlayer();
connection.subscribe(player);

connection.on('stateChange', (oldState, newState) => {
console.log('Voice connection state changed from', oldState.status, 'to', newState.status);

if (oldState.status === VoiceConnectionStatus.Ready && newState.status === VoiceConnectionStatus.Connecting) {
connection.configureNetworking();
}
});

player.on('error', (error) => {
console.error('Audio player error:', error);
});

player.on('stateChange', (oldState, newState) => {
if (oldState.status !== newState.status) {
console.log(`Player state changed from ${oldState.status} to ${newState.status}`);
}

if (newState.status === AudioPlayerStatus.Idle) {
console.log('Audio finished playing!');
player.stop();
connection.destroy();
}
});

if (resource) {
player.play(resource);
console.log('Playing audio...');
interaction.reply({ content: 'Playing audio', ephemeral: true });
} else {
console.error('Failed to create audio resource.');
interaction.reply({ content: 'Failed to create audio resource', ephemeral: true });
}
const resource = createAudioResource('https://cdn.communitydragon.org/15.4.1/champion/gnar/champ-select/sounds/choose');

const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.member.voice.channel.guild.id,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

const player = createAudioPlayer();
connection.subscribe(player);

connection.on('stateChange', (oldState, newState) => {
console.log('Voice connection state changed from', oldState.status, 'to', newState.status);

if (oldState.status === VoiceConnectionStatus.Ready && newState.status === VoiceConnectionStatus.Connecting) {
connection.configureNetworking();
}
});

player.on('error', (error) => {
console.error('Audio player error:', error);
});

player.on('stateChange', (oldState, newState) => {
if (oldState.status !== newState.status) {
console.log(`Player state changed from ${oldState.status} to ${newState.status}`);
}

if (newState.status === AudioPlayerStatus.Idle) {
console.log('Audio finished playing!');
player.stop();
connection.destroy();
}
});

if (resource) {
player.play(resource);
console.log('Playing audio...');
interaction.reply({ content: 'Playing audio', ephemeral: true });
} else {
console.error('Failed to create audio resource.');
interaction.reply({ content: 'Failed to create audio resource', ephemeral: true });
}
pat
pat2w ago
can you try using StreamType.Arbitrary
Sam
SamOP5d ago
I tried that and it didn't fix the issue
const resource = createAudioResource('https://cdn.communitydragon.org/15.4.1/champion/gnar/champ-select/sounds/choose',{
inputType: StreamType.Arbitrary
});
const resource = createAudioResource('https://cdn.communitydragon.org/15.4.1/champion/gnar/champ-select/sounds/choose',{
inputType: StreamType.Arbitrary
});
Here's the report:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5

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

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

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

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

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

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
I will check if this fixes the issue It did not fix the issue. Here's the new report with the updated version:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.18.0
- prism-media: 1.3.5

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

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.15
- @stablelib/xchacha20poly1305: not found
- @noble/ciphers: not found

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

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

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.15
- @stablelib/xchacha20poly1305: not found
- @noble/ciphers: not found

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------

Did you find this page helpful?