Closed rarecrumb closed 7 months ago
These are the options that finally ended up working for me with ElastiCache with Cluster mode and TLS enabled:
clusterRetryStrategy() {
const delay = Math.min(10 * 50, 2000);
return delay;
},
scaleReads: 'slave',
lazyConnect: true,
slotsRefreshInterval: 60000,
slotsRefreshTimeout: 10000,
enableOfflineQueue: true,
enableReadyCheck: true,
redisOptions: {
tls:
process.env.NODE_ENV === "production"
? {
checkServerIdentity: (/*host, cert*/) => {
// skip certificate hostname validation
return undefined;
},
}
: undefined,
commandTimeout: 5000,
connectTimeout: 10000,
lazyConnect: true,
enableReadyCheck: true,
enableAutoPipelining: true,
enableOfflineQueue: true,
noDelay: true,
keepAlive: 1000
}
@ rarecrumb how do you connect to the cluster when developing locally? I'm trying to tunnel via SSH but not sure if that's messing things up.
We were facing a similar issue. This answer from Stack Overflow worked well for us - https://stackoverflow.com/questions/76409668/how-to-connect-to-amazon-memorydb-for-redis-from-node-running-in-ec2-ecs
These are the options that finally ended up working for me with ElastiCache with Cluster mode and TLS enabled:
clusterRetryStrategy() { const delay = Math.min(10 * 50, 2000); return delay; }, scaleReads: 'slave', lazyConnect: true, slotsRefreshInterval: 60000, slotsRefreshTimeout: 10000, enableOfflineQueue: true, enableReadyCheck: true, redisOptions: { tls: process.env.NODE_ENV === "production" ? { checkServerIdentity: (/*host, cert*/) => { // skip certificate hostname validation return undefined; }, } : undefined, commandTimeout: 5000, connectTimeout: 10000, lazyConnect: true, enableReadyCheck: true, enableAutoPipelining: true, enableOfflineQueue: true, noDelay: true, keepAlive: 1000 }
thanks @rarecrumb I tried with your config it working fine.
It seems very common to have issues connecting to AWS ElastiCache in Cluster mode, with TLS enabled.
@luin can you provide examples showing how to use ioredis to connect to Redis Cluster? Extra helpful if it can actually be tested against AWS ElastiCache in Cluster mode with TLS enabled/disabled, password auth enabled/disabled.
ioredis version: v5.3.2 Redis Cluster Engine version: 7.0.7 - TLS Enabled, no password
Errors:
Related issues: