distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
291 stars 50 forks source link

Aborted error #32

Closed TheSainEyereg closed 4 months ago

TheSainEyereg commented 4 months ago

Describe the bug

Crashes during playback when using with Discord.js

Debug File

Error: aborted
    at TLSSocket.socketCloseListener (node:_http_client:460:19)
    at TLSSocket.emit (node:events:530:35)
    at node:net:337:12
    at TCP.done (node:_tls_wrap:657:7) {
  code: 'ECONNRESET'
}
AudioPlayerError: aborted
    at TLSSocket.socketCloseListener (node:_http_client:460:19)
    at TLSSocket.emit (node:events:530:35)
    at node:net:337:12
    at TCP.done (node:_tls_wrap:657:7) {
  resource: AudioResource {
    playStream: Encoder {
      _events: [Object],
      _readableState: [ReadableState],
      _writableState: [WritableState],
      allowHalfOpen: true,
      _maxListeners: undefined,
      _eventsCount: 5,
      encoder: null,
      _options: [Object],
      _required: 3840,
      _buffer: null,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    edges: [ [Object], [Object], [Object] ],
    metadata: null,
    volume: VolumeTransformer {
      _events: [Object],
      _readableState: [ReadableState],
      _writableState: [WritableState],
      allowHalfOpen: true,
      _maxListeners: undefined,
      _eventsCount: 5,
      _readInt: [Function (anonymous)],
      _writeInt: [Function (anonymous)],
      _bits: 16,
      _bytes: 2,
      _extremum: 32768,
      volume: 0.2182910708939091,
      _chunk: null,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    encoder: Encoder {
      _events: [Object],
      _readableState: [ReadableState],
      _writableState: [WritableState],
      allowHalfOpen: true,
      _maxListeners: undefined,
      _eventsCount: 5,
      encoder: null,
      _options: [Object],
      _required: 3840,
      _buffer: null,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    audioPlayer: AudioPlayer {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      _state: [Object],
      subscribers: [Array],
      behaviors: [Object],
      debug: [Function (anonymous)],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false
    },
    playbackDuration: 116980,
    started: true,
    silencePaddingFrames: 5,
    silenceRemaining: -1
  }
}

Btw on original ytdl-core the fix was passing this as options:

{
    filter: "audioonly" as Filter,
    highWaterMark: 1 << 62,
    liveBuffer: 1 << 62,
    dlChunkSize: 0,
    quality: "highestaudio",
}

Environment

skick1234 commented 4 months ago

ECONNRESET means your connection abrupted, maybe due to unstable connection. You can use ytdl.getInfo() to get the stream url, then use @discordjs/voice's createAudioResouce or distube to manage the audio stream instead of ytdl-core, I don't maintain the built-in stream of this fork.

TheSainEyereg commented 4 months ago

means your connection abrupted, maybe due to unstable connection.

Well, it can't be a connection problem since it's present both on the remote server and on my machine.

Thx for answer anyway

ELJoOker2004 commented 4 months ago

same problem after changing from ytdl-core, please update if you found the fix

paullebras commented 4 months ago

I'm also having this same issue, it happens both locally and on the remote server. It does not look like a connexion issue.

dbaldassi commented 3 months ago

I just had also the issue, it seems that I have fixed it by passing the dlChunkSize: 0 to ytdl

let yt = ytdl(url, { filter : 'audioonly', dlChunkSize: 0, agent });
let resource = createAudioResource(yt);
ELJoOker2004 commented 3 months ago

I just had also the issue, it seems that I have fixed it by passing the dlChunkSize: 0 to ytdl

let yt = ytdl(url, { filter : 'audioonly', dlChunkSize: 0, agent });
let resource = createAudioResource(yt);

what is agent?

dbaldassi commented 3 months ago

agent is my cookie

const agent = ytdl.createAgent([/* ... cookie ...*/ ]);