Skip to content

Unable to catch ECONNRESET error and it is causing app to crash. #412

@daveteu

Description

@daveteu

I need some help as your documentation on Client Error handling seems to be gone.

I've searched through forums and issues here. I've followed the recommended actions as follows. However, I'm still not able to catch the errors below, and it's causing my app to crash. My redis servers are all well and not disconnected at that time as I have other services using same server.

Can anyone provide me with some directions?

"@socket.io/redis-adapter": "^7.0.0",
"@socket.io/redis-emitter": "^4.1.0",

Catching error for both sub and pub client - Done ✅

pubClient.on("error", (err) => {
	debug(`REDIS ADAPTOR DISCONNECTED ON pubClient %O`, err)
})
subClient.on("error", (err) => {
	debug(`REDIS ADAPTOR DISCONNECTED ON subClient %O`, err)
})

Catch error on adapter - Done ✅

io.of('/').adapter.on('error', function(error){

	debug('error: ', error);
	
});

Ping to keep connection alive - Done ✅

setInterval(() => {
	// emitter.of('/user').emit("time", new Date);
	io.of('/user').emit("time", new Date())
  }, 300000);

I've also tried using both node-redis and ioredis and both end up with same error below Done ✅

Manage to catch this with redis on error event ✅

 socket REDIS ADAPTOR DISCONNECTED ON pubClient Error: read ECONNRESET
  socket     at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
  socket   errno: -54,
  socket   code: 'ECONNRESET',
  socket   syscall: 'read'
  socket } +5h
  socket error:  Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
} +0ms

Unable to catch this event ❌❌❌

I think this causes my app to crash


events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on RedisAdapter instance at:
    at Redis.onError (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/@socket.io/redis-adapter/dist/index.js:61:22)
    at Redis.emit (events.js:327:22)
    at Redis.EventEmitter.emit (domain.js:486:12)
    at Redis.silentEmit (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/ioredis/built/redis/index.js:544:26)
    at Socket.<anonymous> (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/ioredis/built/redis/event_handler.js:190:14)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:327:22)
    at Socket.EventEmitter.emit (domain.js:486:12)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions