Add 10s connection timeout and retry 10 times max

This commit is contained in:
Hongbo Wu 2022-09-22 13:30:36 +08:00
parent b17fb50c3b
commit d3ad5525e3

View file

@ -7,6 +7,13 @@ export const createRedisClient = async (url?: string, cert?: string) => {
tls: url?.startsWith('rediss://'), // rediss:// is the protocol for TLS
cert: cert?.replace(/\\n/g, '\n'), // replace \n with new line
rejectUnauthorized: false, // for self-signed certs
connectTimeout: 10000, // 10 seconds
reconnectStrategy(retries: number): number | Error {
if (retries > 10) {
return new Error('Retries exhausted')
}
return 1000
},
},
})