ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

ETIMEDOUT error in Redis Sentinel

Open saurabh2608 opened this issue 2 years ago • 5 comments

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

  1. "name"
  2. "mymaster"
  3. "ip"
  4. "172.17.0.4"
  5. "port"
  6. "6379"
  7. "runid"
  8. "0106ee869099d1ca47486e99a1c35b9bc055b15f"
  9. "flags"
  10. "master"
  11. "link-pending-commands"
  12. "0"
  13. "link-refcount"
  14. "1"
  15. "last-ping-sent"
  16. "0"
  17. "last-ok-ping-reply"
  18. "992"
  19. "last-ping-reply"
  20. "992"
  21. "down-after-milliseconds"
  22. "60000"
  23. "info-refresh"
  24. "6306"
  25. "role-reported"
  26. "master"
  27. "role-reported-time"
  28. "8109173"
  29. "config-epoch"
  30. "1"
  31. "num-slaves"
  32. "3"
  33. "num-other-sentinels"
  34. "2"
  35. "quorum"
  36. "2"
  37. "failover-timeout"
  38. "180000"
  39. "parallel-syncs"
  40. "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. (/Users/saurabh.aggarwal/Desktop/test/node_modules/ioredis/built/Redis.js:168:41) at Object.onceWrapper (node:events:509:28) at Socket.emit (node:events:390:28) at Socket._onTimeout (node:net:501:8) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7) { errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' } +10s test: errortesttt: Error: connect ETIMEDOUT at Socket. (/Users/saurabh.aggarwal/Desktop/test/node_modules/ioredis/built/Redis.js:168:41) at Object.onceWrapper (node:events:509:28) at Socket.emit (node:events:390:28) at Socket._onTimeout (node:net:501:8) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7) { errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }

  • 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.

saurabh2608 avatar Nov 16 '22 07:11 saurabh2608

Same Problem. Can somebody help?

MichaelPlan avatar Feb 11 '23 19:02 MichaelPlan

Me too, will try to roll back a few versions and let you guys know what happens.

CrazyByDefault avatar Feb 15 '23 14:02 CrazyByDefault

same problem

untrueme avatar Mar 06 '23 18:03 untrueme

Same here. Seems not to work at all.

yo-han avatar May 23 '23 10:05 yo-han

Same here. Version ^5.3.2

TxusBlack avatar Nov 02 '23 22:11 TxusBlack