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

ECONNRESET #10216

Closed
luigimqf opened this issue Apr 15, 2024 · 3 comments
Closed

ECONNRESET #10216

luigimqf opened this issue Apr 15, 2024 · 3 comments

Comments

@luigimqf
Copy link

luigimqf commented Apr 15, 2024

Which package is this bug report for?

discord.js

Issue description

I'm using discord.js along with discord-player to play music. Other commands are working just fine, but when I use the play command and add music to the queue, the bot stops playing after 40-60 seconds and throws the error below.
I tried reviewing the libs' dependencies and even recreating the bot, but nothing seems to work. I ran out of ideas on how to fix this issue.

Error
node:events:496
    throw er; // Unhandled 'error' event
    ^

Error: read ECONNRESET
  at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on BodyReadable instance at:
  at emitErrorNT (node:internal/streams/destroy:169:8)
  at emitErrorCloseNT (node:internal/streams/destroy:128:3)
  at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
Play Command
const { useMainPlayer } = require("discord-player");
const {
EmbedBuilder,
Application,
ApplicationCommandOptionType,
} = require("discord.js");

const data = {
name: "play",
description: "Play a song",
options: [
  {
    name: "url",
    description: "Nome ou Link da música",
    type: ApplicationCommandOptionType.String,
    required: true,
  },
],
};

async function run({ interaction, client }) {
const player = useMainPlayer(client);

const channel = interaction.member.voice.channel;
if (!channel) return interaction.reply("Você não está em um canal de voz!");

const query = interaction.options.getString("url", true);

const embed = new EmbedBuilder()
  .setAuthor({ name: "Carregando música..." })
  .setColor("#8e44ad");

const reply = await interaction.reply({ embeds: [embed] });

try {
  const { track } = await player.play(channel, query, {
    requestedBy: interaction.user,
  });

  if (track.playlist) {
    embed
      .setAuthor({
        name: `Playlist adicionado á queue`,
        iconURL: client.user.displayAvatarURL(),
      })
      .setDescription(
        `▶️ Adicionado à queue: **${track.playlist.tracks.length} músicas** `
      )
      .setTimestamp()
      .toJSON();

    embed
      .setAuthor({
        name: `Música adicionada à queue!`,
        iconURL: client.user.displayAvatarURL(),
      })
      .setThumbnail(track.thumbnail)
      .setDescription(`▶️  Adicionado à queue: **${track.title}** `)
      .setFooter({
        text: `Comando executado por ${interaction.user.tag}`,
        iconURL: interaction.user.displayAvatarURL(),
      })
      .setTimestamp()
      .toJSON();

    await reply.edit({ embeds: [embed] });
    return;
  }
} catch (error) {
  embed
    .setAuthor({
      name: `Erro ao tocar a música!`,
      iconURL: client.user.displayAvatarURL(),
    })
    .setDescription(`❌ Ocorreu um erro ao tocar a música!`)
    .setFooter({
      text: `Comando executado por ${interaction.user.tag}`,
      iconURL: interaction.user.displayAvatarURL(),
    })
    .setTimestamp()
    .toJSON();
  await reply.edit({ embeds: [embed] });
  return;
}
}

module.exports = { data, run };
package.json
{
"name": "",
"version": "1.0.0",
"main": "index.js",
"scripts": {
  "start": "nodemon ./src/main.js",
  "test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
  "@discord-player/extractor": "^4.4.7",
  "@discordjs/voice": "^0.16.1",
  "commandkit": "^0.1.10",
  "discord-player": "^6.6.8",
  "discord.js": "^14.14.1",
  "dotenv": "^16.4.5",
  "ffmpeg-static": "^5.2.0",
  "genius-lyrics": "^4.4.7",
  "mediaplex": "^0.0.9",
  "youtube-ext": "^1.1.23"
}
}
main.js
const {Client, GatewayIntentBits} = require('discord.js');
const {CommandKit} = require('commandkit');
const path = require('path');
const dotenv = require('dotenv');
const {Player} = require('discord-player');

dotenv.config();

const {Token: TOKEN} = process.env;

const client = new Client({
intents: [
  GatewayIntentBits.Guilds,
  GatewayIntentBits.GuildVoiceStates
]
});

client.config = require('./config');

const player = new Player(client, client.config.opt.discordPlayer);

player.extractors.loadDefault();

new CommandKit({
client,
commandsPath: path.join(__dirname, 'commands'),
eventsPath: path.join(__dirname, 'events'),
});

client.login(TOKEN);

I read some articles about this and its seems unlikely that the error occurs on discord-player side

Versions

  • discord.js: ^14.14.1
  • Node.js: 20.11.1
  • discord-player: ^6.6.8

Issue priority

Medium (should be fixed soon)

Which gateway intents are you subscribing to?

Guilds, GuildVoiceStates

@Qjuh
Copy link
Contributor

Qjuh commented Apr 16, 2024

We don’t support TOS violations.

@almostSouji almostSouji closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@Pablo321123
Copy link

I have the same problem!

@almostSouji
Copy link
Member

If it has to do with discord-player or similar packages or approaches that violate YouTube/other streaming services ToS, we won't help you with it.

In general, ECONNRESET means the TCP connection was terminated unexpectedly without fulfilling your request and is likely not related to the library. If you can reproduce the error in a minimal sample over extended periods of time, consider opening a separate issue.

@discordjs discordjs locked as resolved and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants