fix: configure redis client options and optimize subscriber initialization using duplicate connection
This commit is contained in:
@@ -23,13 +23,20 @@ export class RedisIoAdapter extends IoAdapter {
|
||||
const db = this.configService.get<number>('redis.db', 0);
|
||||
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) {
|
||||
opts.tls = { rejectUnauthorized: false };
|
||||
}
|
||||
|
||||
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}`));
|
||||
subClient.on('error', (err) => this.logger.error(`Redis sub error: ${err.message}`));
|
||||
|
||||
Reference in New Issue
Block a user