ioredis: ClusterAllFailedError: Failed to refresh slots cache.
Hi All. i have following error can You help me ?
[ioredis] Unhandled error event: ClusterAllFailedError: Failed to refresh slots cache.
code is following. `“use strict”; require(‘./config/config’); const Redis = require(‘ioredis’);
(async()=> {
const startupNodes = [
{host: process.env.REDIS_HOST_1, port: process.env.REDIS_PORT },
{host: process.env.REDIS_HOST_2, port: process.env.REDIS_PORT}
];
const options = {
slotsRefreshTimeout: 2000,
dnsLookup: (address, callback) => callback(null, address),
redisOptions: {
tls: {},
password: process.env.REDIS_PASS,
},
};
const cluster = new Redis.Cluster(startupNodes, options);
console.log(cluster);
})();`
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 6
- Comments: 23
Same issue here
Have the same issue. Using an AWS elasticache redis (cluster mode enabled with multiple shards). I get the issue when using in-transit encryption and trying to access behind a NAT instance.
The only fix that seems to work for me is to up the
slotsRefreshTimeout… 😕I wander why the default timeout value is so “dangerously” low. The response to the slots commands just seems to sometimes take 2 or 3 seconds for me. Too bad then that by the time the slots “response” comes the client has already given up…
I suggest setting
DEBUG="ioredis:*"and see if anything turns up. I wonder if it’s still trying to do AUTH.Hi, I have the same issue using AWS ElastiCache & ioredis:
[ElastiCache] Configuration Endpoint:
clustercfg.test1.xxxxxx.use2.cache.amazonaws.com:6379Engine Version Compatibility:5.0.6Parameter Group:default.redis5.0.cluster.on (in-sync)Engine:Engine: Clustered Redis Encryption in-transit: Yes Encryption at-rest: No[ioredis] version:
4.17.3Error:
ClusterAllFailedError: Failed to refresh slots cache.What am I missing ?
We’re having a similar issue. Redis version: 5.0.4 on AWS ElasticCache Clustered (3 nodes, 1 shard) ioredis version: 4.16.0
Code to connect:
This code works, but bypasses the cluster for reads, if I understand it correctly:
I can also connect via
redis-cli -h <PRIMARY_RW_ENDPOINT>, so I’m sure VPC, Subnet and Security groups are all correct.I found my mistake, I’m new into ElastiCache and I didn’t realize I need to connect from an EC2 or AWS VPN. I fixed that and it worked.
I guess you’re missing
tls.checkServerIdentityand a password, if AUTH is enabled.I can’t vouch for all of the following, but FYI:
FWIW, I know this issue is re: clustered but I was fighting with this as well (in-transit encryption on, passworded redis) and this connection string finally got me going, I expect it’d work with a cluster as well:
It’s not working with https://github.com/bitnami/bitnami-docker-redis-cluster
fixes like
checkServerIdentityreturningundefined, DNS lookup, and other proposed fixes. ioRedis version:4.28.1The following works for me.
Redis version: 5.0.4 on AWS ElasticCache Clustered with TLS and AUTH enabled. ioredis version: 4.16.0
Code to connect:
Make sure you are in the right VPC, Subnet and Security group to connect to ElastiCache along with the correct IAM role