-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Hi,
I have a TypeScript application in which I am using the new socket.reconnectStrategy
option described in https://github.com/redis/node-redis/blob/master/docs/client-configuration.md#reconnect-strategy.
However, this does not seem to be applied. After stopping the Redis server, the reconnecting
event is still fired within the default delay of 500ms. But according to my configuration, this should happen after 3000ms.
My code:
(async () => {
try {
const client = createClient({ socket: { host: '127.0.0.1', port: 6379, connectTimeout: 3000, reconnectStrategy: (_retryAttempt: number): number | Error => 3000 } })
client.on('connect', () => {
console.info('Redis client is connecting to redis://127.0.0.1:6379...')
})
client.on('ready', () => {
console.info('Redis client is connected')
})
client.on('reconnecting', () => {
console.info('Redis client is reconnecting...')
})
client.on('error', error => {
console.error(`Redis client error: ${JSON.stringify(error)}`)
})
await client.connect().catch(error => console.error(JSON.stringify(error)))
} catch (error) {
console.error(`Service start error: ${JSON.stringify(error)}`)
}
})().catch(() => {})
Environment:
- Node.js Version: 14.16.1
- Redis Server Version: 6.2.0
- Node Redis Version: 4.0.3
- Platform: Windows 10