node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Redis client goes offline after restarting the redis server several times

Open aikms-maker opened this issue 2 years ago • 1 comments

Description

Code is written in NestJS If I repeatedly stop and start the redis server several times while the application is running, the redis client goes offline and cannot connect. When connecting from the application, the following error log is output.

ERROR [ExceptionsHandler] The client is offline

RedisClientOptions is defined as follows

const redisClientOptions: RedisClientOptions = {
      url: 'redis:/127.0.0.1:6379',
      database: 1,
      disableOfflineQueue: true, }
    };

If I don't specify database the reconnect is working fine but I want to specify database as 1. We expect the client to reconnect successfully no matter how many times we restart the Redis server.

I have prepared the code at the following URL https://github.com/aikms-maker/nest-node-redis

Node.js Version

v18.12.1

Redis Server Version

6.0.14

Node Redis Version

4.6.8

Platform

Linux, docker redis:6.0.14 container

Logs

No response

aikms-maker avatar Sep 13 '23 04:09 aikms-maker

take care about disableOfflineQueue: When true, commands are rejected when the client is reconnecting.

daniel-tuix avatar Oct 17 '23 20:10 daniel-tuix