You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to connect to redis enterprise cluster instance but getting this error again and again
I tried to connect using redis-cli its working fine but when i am trying to use ioredis and below code its giving error
These are the timeouts I am using
ioredis: ^5.5.0
Trying to connect to redis enterprise cluster instance but getting this error again and again
I tried to connect using redis-cli its working fine but when i am trying to use ioredis and below code its giving error
These are the timeouts I am using
Application runtime settings
REDIS_CLUSTER=true
REDIS_SSL=true
CACHE_TTL=7200
SHORT_TTL=7200
MEDIUM_TTL=14400
LONG_TTL=28800
REDIS_KEY_SCAN_LIMIT=50000
REDIS_CONNECT_TIMEOUT=10000
REDIS_CLUSTER_CONNECT_TIMEOUT=20000
REDIS_CLUSTER_SLOT_REFRESH_INTERVAL=5000
REDIS_CLUSTER_SLOT_REFRESH_TIMEOUT=60000
REDIS_CLUSTER_RETRY_BASE_DELAY=100
REDIS_CLUSTER_RETRY_MAX_DELAY=5000
REDIS_CLUSTER_KEY_SCAN_LIMIT=50000
export function getRedisInstance(connectionName: string) {
let redisInstance;
const startTime = process.hrtime();
console.log(
redis connection:${connectionName}
);try {
if (cache.cluster && cache.tls) {
redisInstance = new Redis.Cluster(
[
{
host: cache.hostname,
port: cache.port,
},
],
{
dnsLookup: (address, callback) => callback(null, address, 4),
redisOptions: {
...(cache.tls && {
tls: {
host: cache.hostname,
servername: cache.hostname,
rejectUnauthorized: false,
checkServerIdentity: (servername, cert) => {
// skip certificate hostname validation
return undefined;
},
},
}),
password: cache.password,
connectionName: connectionName,
showFriendlyErrorStack: true,
connectTimeout: redisClusterConfig.connectTimeout,
keepAlive: 1,
},
slotsRefreshInterval: redisClusterConfig.slotsRefreshInterval, // Increase interval to 5 seconds
slotsRefreshTimeout: redisClusterConfig.slotsRefreshTimeout, // Increase timeout to 60 seconds
enableReadyCheck: true,
clusterRetryStrategy: (times) => {
const delay = Math.min(times * redisClusterConfig.retryBaseDelay, redisClusterConfig.retryMaxDelay);
console.log(
Retrying after ${delay}ms
);return delay;
},
}
);
// Log errors for debugging
redisInstance.on('ready', () => {
// Log request time taken
console.log(
Total time taken to connnect to redis server: ${DateTimeUtility.prototype.parseHrtimeToSeconds(process.hrtime(startTime))} seconds
);
console.log('Cluster is ready!');
});
redisInstance.on('error', (err) => {
console.log(
Redis error: ${err}
);});
} else if (!cache.cluster && cache.tls) {
const url =
rediss://:${cache.password}@${cache.hostname}:${cache.port}
;redisInstance = new Redis(url, {
connectionName: connectionName,
});
} else {
redisInstance = new Redis({
port: cache.port,
host: cache.hostname,
family: 4,
password: cache.password,
connectTimeout: redisConfig.connectTimeout,
connectionName: connectionName,
});
}
} catch (error) {
console.log(
Redis connection creation error, connection name: ${connectionName}, ${error}
);console.log(
connection details, host:${cache.hostname},port:${cache.port}
);throw error;
}
return redisInstance;
}
The text was updated successfully, but these errors were encountered: