got: RequestError: read ECONNRESET

Describe the bug

  • Node.js version: 16.6
  • OS & version: Windows 10 , 21H2

I use Got stream as a way to play music songs in discord.js bot. Whenever I do that, after 2 minutes, the connections gets disconnected and I get this Error RequestError: read ECONNRESET

Actual behavior

Gives error : RequestError: read ECONNRESET

Expected behavior

It should have played all song completely without any issues.

Code to reproduce

got.stream(final.url, {
        retry : 5,
        headers: {
            'Connection': 'keep-alive',
            'Accept-Encoding': '',
            'Accept-Language': 'en-US,en;q=0.8'
        }
    })

Full ERROR, here :

  resource: <ref *3> AudioResource {
    playbackDuration: 134220,
    started: true,
    silenceRemaining: -1,
    edges: [
      <ref *1> {
        type: 'webm/opus demuxer',
        to: Node { edges: [ [Object] ], type: 'opus' },
        cost: 1,
        transformer: [Function: transformer],
        from: Node {
          edges: [ [Circular *1], [Object], [Object] ],
          type: 'webm/opus'
        }
      }
    ],
    playStream: WebmDemuxer {
      _readableState: ReadableState {
        objectMode: true,
        highWaterMark: 16,
        buffer: BufferList {
          head: { data: [Buffer [Uint8Array]], next: [Object] },
          tail: { data: [Buffer [Uint8Array]], next: null },
          length: 154
        },
        length: 154,
        pipes: [],
        flowing: null,
        ended: false,
        endEmitted: false,
        reading: false,
        constructed: true,
        sync: false,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        errorEmitted: true,
        emitClose: true,
        autoDestroy: true,
        destroyed: true,
        errored: RequestError: read ECONNRESET
            at ClientRequest.<anonymous> (C:\Users\**SOME PATH**\aio-discord-bot\main\node_modules\got\dist\source\core\index.js:956:111)
            at Object.onceWrapper (node:events:514:26)
            at ClientRequest.emit (node:events:406:35)
            at ClientRequest.origin.emit (C:\Users\**SOME PATH**\aio-discord-bot\main\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
            at TLSSocket.socketErrorListener (node:_http_client:447:9)
            at TLSSocket.emit (node:events:394:28)
            at emitErrorNT (node:internal/streams/destroy:157:8)
            at emitErrorCloseNT (node:internal/streams/destroy:122:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21)
            at TLSWrap.onStreamRead (node:internal/stream_base_commons:211:20) {
          code: 'ECONNRESET',
          timings: {
            start: 1629183240852,
            socket: 1629183240852,
            lookup: 1629183240852,
            connect: 1629183240868,
            secureConnect: 1629183240889,
            upload: 1629183240889,
            response: 1629183240924,
            end: undefined,
            error: 1629183376211,
            abort: 1629183376211,
            phases: [Object]
          }
        },
        closed: true,
        closeEmitted: false,
        defaultEncoding: 'utf8',
        awaitDrainWriters: null,
        multiAwaitDrain: false,
        readingMore: false,
        decoder: null,
        encoding: null,
        [Symbol(kPaused)]: null
      },
      _events: [Object: null prototype] {
        prefinish: [Function: prefinish],
        close: [ [Function (anonymous)], [Function: onclose] ],
        end: [Function: onend],
        finish: [Function: onfinish],
        error: [Function: onerror]
      },
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: true,
        ending: false,
        ended: false,
        finished: false,
        destroyed: true,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 16384,
        writing: true,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: [Function: nop],
        writelen: 16384,
        afterWriteTickInfo: null,
        buffered: [],
        bufferedIndex: 0,
        allBuffers: true,
        allNoop: true,
        pendingcb: 1,
        constructed: true,
        prefinished: false,
        errorEmitted: true,
        emitClose: true,
        autoDestroy: true,
        errored: RequestError: read ECONNRESET
            at ClientRequest.<anonymous> (C:\Users\**SOME PATH**\aio-discord-bot\main\node_modules\got\dist\source\core\index.js:956:111)
            at Object.onceWrapper (node:events:514:26)
            at ClientRequest.emit (node:events:406:35)
            at ClientRequest.origin.emit (C:\Users\**SOME PATH**\aio-discord-bot\main\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
            at TLSSocket.socketErrorListener (node:_http_client:447:9)
            at TLSSocket.emit (node:events:394:28)
            at emitErrorNT (node:internal/streams/destroy:157:8)
            at emitErrorCloseNT (node:internal/streams/destroy:122:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21)
            at TLSWrap.onStreamRead (node:internal/stream_base_commons:211:20) {
          code: 'ECONNRESET',
          timings: {
            start: 1629183240852,
            socket: 1629183240852,
            lookup: 1629183240852,
            connect: 1629183240868,
            secureConnect: 1629183240889,
            upload: 1629183240889,
            response: 1629183240924,
            end: undefined,
            error: 1629183376211,
            abort: 1629183376211,
            phases: [Object]
          }
        },
        closed: true,
        closeEmitted: false,
        [Symbol(kOnFinished)]: []
      },
      allowHalfOpen: true,
      _remainder: null,
      _length: 851968,
      _count: 851859,
      _skipUntil: null,
      _track: { number: 1, type: 2 },
      _incompleteTrack: {},
      _ebmlFound: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    metadata: null,
    silencePaddingFrames: 5,
    audioPlayer: <ref *2> AudioPlayer {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined,
      subscribers: [
        PlayerSubscription {
          connection: VoiceConnection {
            _events: [Object: null prototype] {},
            _eventsCount: 0,
            _maxListeners: undefined,
            debug: null,
            rejoinAttempts: 0,
            onNetworkingClose: [Function: bound onNetworkingClose],
            onNetworkingStateChange: [Function: bound onNetworkingStateChange],
            onNetworkingError: [Function: bound onNetworkingError],
            onNetworkingDebug: [Function: bound onNetworkingDebug],
            _state: [Object],
            packets: [Object],
            joinConfig: [Object],
            [Symbol(kCapture)]: false
          },
          player: [Circular *2]
        }
      ],
      _state: {
        status: 'playing',
        playbackDuration: 134220,
        resource: [Circular *3],
        onStreamError: [Function: onStreamError]
      },
      behaviors: { noSubscriber: 'play', maxMissedFrames: 5 },
      debug: [Function (anonymous)],
      [Symbol(kCapture)]: false
    }
  }
}

Checklist

  • [πŸ‘ ] I have read the documentation.
  • [πŸ‘ ] I have tried my code with the latest version of Node.js and Got.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 20

Most upvoted comments

Next time please make sure what you’re reporting is really a bug, thanks πŸ˜ƒ