discord.js: ECONNRESET

Please describe the problem you are having in as much detail as possible:

Error: read ECONNRESET
at exports._errnoException (util.js:1022:11)
at TLSWrap.onread (net.js:569:26)

I’ve tried catching it in client disconnect and error events, yet they both don’t seem to be getting called. Supposedly this was supposed to be fixed over a year ago in: https://github.com/hydrabolt/discord.js/issues/694

Further details:

  • discord.js version: 11.2.1
  • node.js version: v8.9.4
  • Operating system: Windows 10
  • Priority this issue should have – please be realistic and elaborate if possible: This causes my bot to crash constantly and I cannot restart it, even with pm2. So pretty high for me.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 37 (12 by maintainers)

Most upvoted comments

Well the only fix i know for this is, Your Internet

The ECONRESET means the process lost connection to the internet for too long, causing it to die

The fix for me was making a direct ethernet cable from my router to my raspberry pi

i get randomly mostly the same Error (at “2018-04-12T15:59:34.192Z”)

{ Error: Unhandled "error" event. ([object Object])
    at Client.emit (events.js:186:19)
    at WebSocketConnection.onError (R:\Visual Studio\Projects\sylvi_remake\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
    at WebSocket.onError (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at _receiver.cleanup (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\websocket.js:211:14)
    at Receiver.cleanup (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\receiver.js:557:13)
    at WebSocket.finalize (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\websocket.js:206:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
  context:
   ErrorEvent {
     target:
      WebSocket {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        readyState: 2,
        protocol: '',
        _binaryType: 'nodebuffer',
        _finalize: [Function: bound finalize],
        _closeFrameReceived: false,
        _closeFrameSent: false,
        _closeMessage: '',
        _closeTimer: null,
        _finalized: true,
        _closeCode: 1006,
        _extensions: {},
        _isServer: false,
        _receiver: [Object],
        _sender: [Object],
        _socket: [Object],
        _error: null,
        url: 'wss://gateway.discord.gg/?v=6&encoding=etf',
        _req: null },
     type: 'error',
     message: 'read ECONNRESET',
     error: { Error: read ECONNRESET
    at _errnoException (util.js:1022:11)
    at TLSWrap.onread (net.js:628:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' } } }

(using newset discord.js from npm)

i handle the client errors (console.log) and still get:

{ Error: Unhandled "error" event. ([object Object])
    at VoiceWebSocket.emit (events.js:186:19)
    at VoiceWebSocket.onError (R:\Visual Studio\Projects\sylvi_remake\node_modules\discord.js\src\client\voice\VoiceWebSocket.js:156:10)
    at WebSocket.onError (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at _receiver.cleanup (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\websocket.js:211:14)
    at Receiver.cleanup (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\receiver.js:535:15)
    at WebSocket.finalize (R:\Visual Studio\Projects\sylvi_remake\node_modules\ws\lib\websocket.js:206:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
  context:
   ErrorEvent {
     target:
      WebSocket {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        readyState: 2,
        protocol: '',
        _binaryType: 'nodebuffer',
        _finalize: [Function: bound finalize],
        _closeFrameReceived: true,
        _closeFrameSent: true,
        _closeMessage: '',
        _closeTimer: [Object],
        _finalized: true,
        _closeCode: 1005,
        _extensions: {},
        _isServer: false,
        _receiver: [Object],
        _sender: [Object],
        _socket: [Object],
        _error: null,
        url: 'wss://eu-central124.discord.gg',
        _req: null },
     type: 'error',
     message: 'read ECONNRESET',
     error: { Error: read ECONNRESET
    at _errnoException (util.js:1022:11)
    at TLSWrap.onread (net.js:628:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' } } }

I also get this on latest master. It’s rare but it happens. I don’t use any kind of voice features.

EDIT: could add pics since it happened again on two of my bots. Both still on latest master as of the day i posted the comment. error-image01 error-image02

It should definitely be fixed in voice-rewrite, not too sure about 11.2.1.