fix: configure redis client options and optimize subscriber initialization using duplicate connection

This commit is contained in:
pradeepkumar
2026-04-07 13:17:18 +05:30
parent 44de2aeaa9
commit 35b85c1cc0

View File

@@ -23,13 +23,20 @@ export class RedisIoAdapter extends IoAdapter {
const db = this.configService.get<number>('redis.db', 0); const db = this.configService.get<number>('redis.db', 0);
const useTls = process.env.REDIS_TLS === 'true'; const useTls = process.env.REDIS_TLS === 'true';
const opts: any = { host, port, password, db }; const opts: any = {
host,
port,
password,
db,
maxRetriesPerRequest: null,
enableReadyCheck: false,
};
if (useTls) { if (useTls) {
opts.tls = { rejectUnauthorized: false }; opts.tls = { rejectUnauthorized: false };
} }
const pubClient = new Redis(opts); const pubClient = new Redis(opts);
const subClient = new Redis(opts); const subClient = pubClient.duplicate();
pubClient.on('error', (err) => this.logger.error(`Redis pub error: ${err.message}`)); pubClient.on('error', (err) => this.logger.error(`Redis pub error: ${err.message}`));
subClient.on('error', (err) => this.logger.error(`Redis sub error: ${err.message}`)); subClient.on('error', (err) => this.logger.error(`Redis sub error: ${err.message}`));