Azure Cache for Redis failover reconnect
Someone
20
Reputation points
I'm using Azure Cache for Redis.
When using the node-redis package to connect to Redis in Node.js, there's an issue with automatically reconnecting when Redis doing an upgrade. In .NET, you can use ForceReconnect, but how can this be implemented in Node.js?
Here are the settings:
const redisConfig = {
url: `redis://${REDIS_HOST}:${REDIS_PORT}`,
socket: {
host: REDIS_HOST,
port: Number(REDIS_PORT),
reconnectStrategy: (retries) => (retries < 5 ? 100 : 5000),
},
password: REDIS_PWD,
database: Number(REDIS_DB_NUMBER),
// Azure Redis has a 10-minute timeout for idle connections
pingInterval: 4 * 60 * 1000,
};
Sign in to answer