question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto reconnect doesn't work under certains circumstances

See original GitHub issue

Hello,

When ready check is on and an MaxRetriesPerRequestError happens, a recoverFromFatalError is called in the ready check causing disconnect(true) to be called and will lead to abort to reconnection process.

This is leading us in a situation where express session associated to redisStore isn’t working anymore.

a quick and dirty fix for us is to disable ready check or set MaxRetriesPerRequest to -1

Our case to test the bug:

ioredis express client connected as a standalone redis configuration to redis-ha chart with haproxy enabled and 3 redis/sentinel behind. (haproxy is routing all requests to the master node) kill or scale to 0 haproxy. ioredis is entering the autoreconnect loop (with retrystrategy)

Adding this stack to help :

programname programname 2019-11-20T08:58:29.197Z ioredis:redis status[10.19.246.167:6379 (clientname)]: close -> reconnecting
programname programname 2019-11-20T08:58:29.197Z ioredis:connection reach maxRetriesPerRequest limitation, flushing command queue... v1
programname programname 2019-11-20T08:58:29.197Z ioredis:connection reach maxRetriesPerRequest limitation, flushing command queue... DONE v1
programname programname 2019-11-20T08:58:29.197Z ioredis:redis recoverFromFatalError MaxRetriesPerRequestError: Reached the max retries per request limit (which is 1). Refer to "maxRetriesPerRequest" option for details.
programname programname 2019-11-20T08:58:29.198Z ioredis:redis DISCONNECT CALLED v2 true
programname programname Trace
programname programname     at Redis.disconnect (/snapshot/programname/node_modules/ioredis/built/redis/index.js:323:10)
programname programname     at Redis.recoverFromFatalError (/snapshot/programname/node_modules/ioredis/built/redis/index.js:365:10)
programname programname     at /snapshot/programname/node_modules/ioredis/built/redis/event_handler.js:53:30
programname programname     at /snapshot/programname/node_modules/ioredis/built/redis/index.js:436:20
programname programname     at tryCatcher (/snapshot/programname/node_modules/standard-as-callback/built/utils.js:11:23)
programname programname     at promise.then (/snapshot/programname/node_modules/standard-as-callback/built/index.js:30:51)
programname programname     at process._tickCallback (internal/process/next_tick.js:68:7)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:9

github_iconTop GitHub Comments

6reactions
shizhxcommented, Mar 30, 2020

reproduced method:

  1. redis-server not started
  2. new Redis() and call any command, e.g. get
  3. ioredis will connect failed and retry(enable DEBUG and print retryAttempts)
  4. once retryAttempts reach 20, start netcat nc -l 6379 as a fake redis-server
  5. wait for a whlie, once ioredis connected to netcat and info command written, stop netcat
  6. ioredis will reconnect and the reconnectTimeout task would always canceled by recoverFromFatalError
  7. ioredis dead and get command will never return
2reactions
tupizzcommented, Jul 15, 2020

The error still here, even with the version 4.17.3…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android 11 lets you not automatically connect to specific Wi-Fi ...
Android 11 has a new toggle in the settings panel for Wi-Fi networks called 'Auto-connect,' and when it is switched off, your device...
Read more >
[SOLVED] Reconnect ESP8266 NodeMCU to Wi-Fi Network ...
To reconnect to Wi-Fi after a connection is lost, you can use WiFi.setAutoReconnect(true); followed by WiFi.persistent(true); to automatically reconnect to the ...
Read more >
Fix: Windows 10 will not connect to WIFI Automatically - Appuals
Then from under Manage Known Networks, Click the name of your wireless network and choose Forget. Restart your computer. Click on the WiFi...
Read more >
Mongoose autoReconnect option - node.js - Stack Overflow
I'm attaching that event to the return of this createConnection() call. My events are working normally with the connected / disconnected events. –...
Read more >
iPhone Won't Auto-Connect to WiFi – How to Fix - Alphr
Naturally, the first thing you should try is restarting your Wi-Fi connection. Turn your Wi-Fi off and on in the Settings app or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found