diff --git a/src/integrations/redis/redis.client.ts b/src/integrations/redis/redis.client.ts index 44a22a2..c4be79f 100644 --- a/src/integrations/redis/redis.client.ts +++ b/src/integrations/redis/redis.client.ts @@ -29,9 +29,13 @@ export class RedisClient implements OnModuleDestroy { } try { - const pong = String( - await this.withTimeout(this.getClient(redisUrl).ping()), - ); + const client = this.getClient(redisUrl); + + if (client.status === 'wait' || client.status === 'end') { + await this.withTimeout(client.connect()); + } + + const pong = String(await this.withTimeout(client.ping())); return pong === 'PONG' ? { status: 'ok' } @@ -62,7 +66,7 @@ export class RedisClient implements OnModuleDestroy { this.client = new Redis(redisUrl, { connectTimeout: redisPingTimeoutMs, enableOfflineQueue: false, - lazyConnect: false, + lazyConnect: true, maxRetriesPerRequest: 1, }); this.client.on('error', () => undefined);