Redis Client Error: Error: All sentinels are unreachable. Retrying from scratch after 50ms. Last error: Connection is closed. #1777
Open
Description
@luin I am getting the below issue. Even though all my sentinels are accessible and are running fine.
Version: "ioredis": "^5.3.2"
Node.js v16.15.1.
My test code:
import Redis from 'ioredis';
const createRedisClient = () => {
return new Redis({
sentinels: [
{ host: "localhost", port: 26380 },
{ host: "localhost", port: 26381 },
{ host: "localhost", port: 26382 }
],
name: "mymaster",
password: "password",
sentinelRetryStrategy: (times) => {
// reconnect after
return Math.min(times * 50, 2000);
}
});
}
const connectRedis = () => {
const redisClient = createRedisClient();
// handle events
redisClient.on('connect', () => console.log('<:: Redis Client Connected'));
redisClient.on('error', (err) => console.error('<:: Redis Client Error: ', err));
return redisClient;
}
connectRedis();
Error:-
}
<:: Redis Client Error: Error: connect ETIMEDOUT
at Socket.<anonymous> (/Users/raman/Desktop/docker_k8/redissentinal/test/node_modules/ioredis/built/Redis.js:170:41)
at Object.onceWrapper (node:events:641:28)
at Socket.emit (node:events:527:28)
at Socket._onTimeout (node:net:516:8)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect'
}
<:: Redis Client Error: Error: connect ETIMEDOUT
at Socket.<anonymous> (/Users/raman/Desktop/docker_k8/redissentinal/test/node_modules/ioredis/built/Redis.js:170:41)
at Object.onceWrapper (node:events:641:28)
at Socket.emit (node:events:527:28)
at Socket._onTimeout (node:net:516:8)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect'
}
<:: Redis Client Error: Error: All sentinels are unreachable. Retrying from scratch after 50ms. Last error: Connection is closed.
at connectToNext (/Users/raman/Desktop/docker_k8/redissentinal/test/node_modules/ioredis/built/connectors/SentinelConnector/index.js:64:31)
at connectToNext (/Users/raman/Desktop/docker_k8/redissentinal/test/node_modules/ioredis/built/connectors/SentinelConnector/index.js:117:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
All docker containers are up and running fine
sentinel.conf
port 26379
dir /tmp
sentinel resolve-hostnames yes
sentinel monitor mymaster redis-master 6379 $SENTINEL_QUORUM
sentinel auth-pass mymaster $REDIS_PASSWORD
sentinel down-after-milliseconds mymaster $SENTINEL_DOWN_AFTER
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster $SENTINEL_FAILOVER
sentinel deny-scripts-reconfig yes
sentinel-entrypoint.sh
#!/bin/sh
sed -i "s/\$SENTINEL_QUORUM/$SENTINEL_QUORUM/g" /redis/sentinel.conf
sed -i "s/\$REDIS_PASSWORD/$REDIS_PASSWORD/g" /redis/sentinel.conf
sed -i "s/\$SENTINEL_DOWN_AFTER/$SENTINEL_DOWN_AFTER/g" /redis/sentinel.conf
sed -i "s/\$SENTINEL_FAILOVER/$SENTINEL_FAILOVER/g" /redis/sentinel.conf
redis-server /redis/sentinel.conf --sentinel
Metadata
Assignees
Labels
No labels