ioredis
ioredis copied to clipboard
ETIMEDOUT error in Redis Sentinel
Hi guys, I observe a very strange connection issue. I have setup with 3 Sentinels with Quorum 2 - I have 2 slaves and 1 master.
I have setup my local system using the url https://medium.com/@talk2amareswaran/redis-sentinel-the-high-availability-for-redis-using-docker-5495e0173559
The configuration information of redis sentinel setup is this ` Saurabhs-MacBook-Air:~ saurabh.aggarwal$ redis-cli -p 26379 sentinel master mymaster
- "name"
- "mymaster"
- "ip"
- "172.17.0.4"
- "port"
- "6379"
- "runid"
- "0106ee869099d1ca47486e99a1c35b9bc055b15f"
- "flags"
- "master"
- "link-pending-commands"
- "0"
- "link-refcount"
- "1"
- "last-ping-sent"
- "0"
- "last-ok-ping-reply"
- "992"
- "last-ping-reply"
- "992"
- "down-after-milliseconds"
- "60000"
- "info-refresh"
- "6306"
- "role-reported"
- "master"
- "role-reported-time"
- "8109173"
- "config-epoch"
- "1"
- "num-slaves"
- "3"
- "num-other-sentinels"
- "2"
- "quorum"
- "2"
- "failover-timeout"
- "180000"
- "parallel-syncs"
- "1" Saurabhs-MacBook-Air:~ saurabh.aggarwal$ redis-cli -p 26379 INFO sentinel
Sentinel
sentinel_masters:1 sentinel_tilt:0 sentinel_tilt_since_seconds:-1 sentinel_running_scripts:0 sentinel_scripts_queue_length:0 sentinel_simulate_failure_flags:0 master0:name=mymaster,status=ok,address=172.17.0.4:6379,slaves=3,sentinels=3`
Now When I have written the code its showing issue, sample code is here
`const Redis = require("ioredis"); const redis = new Redis({ port: 6379, // maxRetriesPerRequest: 1, connectTimeout: 10000, sentinels: [ { port: 26379, host: "localhost", }, { port: 26380, host: "localhost", }, { port: 26381, host: "localhost", }, ], name: "mymaster", });
redis.on("error", function (err) { console.log("test:"); if (err) { console.log("errortesttt:", err); } });
redis.on("connect", () => { console.log("CacheStore - Connection status: connected"); });
redis.set("mykey", "value"); redis.get("mykey", (err, result) => { if (err) { console.error(err); } else { console.log(result); // Prints "value" } });`
I am facing this issue
ioredis:redis status[localhost:6379]: wait -> connecting +0ms
ioredis:redis status[localhost:26379]: wait -> connecting +1ms
ioredis:redis queue command[localhost:26379]: 0 -> sentinel([ 'get-master-addr-by-name', 'mymaster' ]) +1ms
ioredis:redis queue command[localhost:6379]: 0 -> get([ 'mykey' ]) +1ms
ioredis:redis status[127.0.0.1:26379]: connecting -> connect +3ms
ioredis:redis write command[127.0.0.1:26379]: 0 -> info([]) +1ms
ioredis:redis status[127.0.0.1:26379]: connect -> ready +2ms
ioredis:connection send 1 commands in offline queue +0ms
ioredis:redis write command[127.0.0.1:26379]: 0 -> sentinel([ 'get-master-addr-by-name', 'mymaster' ]) +0ms
ioredis:redis write command[127.0.0.1:26379]: 0 -> sentinel([ 'sentinels', 'mymaster' ]) +1ms
ioredis:SentinelConnector adding sentinel 172.17.0.7:26380 +0ms
ioredis:SentinelConnector adding sentinel 172.17.0.8:26381 +1ms
ioredis:SentinelConnector Updated internal sentinels: [{"port":26379,"host":"localhost"},{"port":26380,"host":"localhost"},{"port":26381,"host":"localhost"},{"host":"172.17.0.7","port":26380},{"host":"172.17.0.8","port":26381}] @1 +0ms
ioredis:SentinelConnector resolved: 172.17.0.4:6379 from sentinel localhost:26379 +0ms
ioredis:redis status[127.0.0.1:26379]: ready -> close +3ms
ioredis:connection skip reconnecting since the connection is manually closed. +4ms
ioredis:redis status[127.0.0.1:26379]: close -> end +0ms
ioredis:connection error: Error: connect ETIMEDOUT
at Socket.
- Have anybody gone through this type of issue?
- can anybody please suggest or give an alternative to clear this issue.
- I have to connect it with sentinel only.
Same Problem. Can somebody help?
Me too, will try to roll back a few versions and let you guys know what happens.
same problem
Same here. Seems not to work at all.
Same here. Version ^5.3.2