-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection Instability with socketTimeout
Parameter
#1919
Labels
Comments
The actual error:
|
bobymicroby
added a commit
to bobymicroby/ioredis
that referenced
this issue
Dec 20, 2024
…#1919) The issue occurs when using socketTimeout, causing connections to become unstable with repeated disconnections and reconnections. This happens due to incorrect ordering of socket stream event handling. Changes: - Use prependListener() instead of on() for `DataHandler` stream data events - Explicitly call resume() after attaching the `DataHandler` stream listener - Add tests to verify socket timeout behavior This ensures the parser receives and processes data before timeout checks, preventing premature timeouts and connection instability. Fixes redis#1919
bobymicroby
added a commit
to bobymicroby/ioredis
that referenced
this issue
Dec 20, 2024
The issue occurs when using socketTimeout, causing connections to become unstable with repeated disconnections and reconnections. This happens due to incorrect ordering of socket stream event handling. Changes: - Use prependListener() instead of on() for `DataHandler` stream data events - Explicitly call resume() after attaching the `DataHandler` stream listener - Add tests to verify socket timeout behavior This ensures the parser receives and processes data before timeout checks, preventing premature timeouts and connection instability. Fixes redis#1919
🎉 This issue has been resolved in version 5.4.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@pinkiesky Thanks for opening this issue and submitting the fix! Your contribution is much appreciated! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When setting the socketTimeout parameter to a non-zero value, the Redis connection becomes unstable after startup. The connection repeatedly closes due to the socketTimeout mechanism, reconnects, and then falls into a loop of closing and reconnecting.
Code for the bug reproduction
Here’s a typical log output from running the code:
In this example, the connection eventually stabilized after 10 reconnection attempts, but the number of attempts seems random and can vary between runs. My tests often have 2-3 reconnections, but this may differ for others.
My environment:
The text was updated successfully, but these errors were encountered: