Azure Cache for Redis failover reconnect

Someone 20 Reputation points
2024-08-02T06:28:20.9666667+00:00

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,
};
Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
250 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.