I have implemented Pub/Sub pattern using ioredis. For past few days i get below error frequently and pod where the app is deployed frequently restarts . Wanted to know if node app restarts due to this error?Or this error is due to node app crashing
self.flushQueue(new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG))
^
Error: Connection is closed.
at close (/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:189:25)
at TLSSocket. (/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:156:20)
at Object.onceWrapper (node:events:628:26)
at TLSSocket.emit (node:events:525:35)
at node:net:301:12
at TCP.done (node:_tls_wrap:588:7)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
Sample code below:
async subscribeToChannel(channelName) {
this.logger.debug('cannot aquire lock - redis is locked');
const redisSub = this.getRedisInstance();
//Subscribe to channel
redisSub.subscribe(channelName, (err, data) => {
this.logger.debug('client subscribed');
});
return await new Promise((resolve, reject) => {//Wait for message event
redisSub.on('message', (channel, message) => {
this.logger.debug(Received the following message from ${channel});
resolve(JSON.parse(message));//Return data
redisSub.unsubscribe();//Unsubscribe
redisSub.quit();//Close connection
});
})
}
I have implemented Pub/Sub pattern using ioredis. For past few days i get below error frequently and pod where the app is deployed frequently restarts . Wanted to know if node app restarts due to this error?Or this error is due to node app crashing
/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:189
self.flushQueue(new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG)) ^ Error: Connection is closed. at close (/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:189:25) at TLSSocket. (/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:156:20)
at Object.onceWrapper (node:events:628:26)
at TLSSocket.emit (node:events:525:35)
at node:net:301:12
at TCP.done (node:_tls_wrap:588:7)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
Sample code below: async subscribeToChannel(channelName) { this.logger.debug('cannot aquire lock - redis is locked'); const redisSub = this.getRedisInstance(); //Subscribe to channel redisSub.subscribe(channelName, (err, data) => { this.logger.debug('client subscribed'); }); return await new Promise((resolve, reject) => {//Wait for message event redisSub.on('message', (channel, message) => { this.logger.debug(
Received the following message from ${channel}
); resolve(JSON.parse(message));//Return data redisSub.unsubscribe();//Unsubscribe redisSub.quit();//Close connection }); }) }