-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
SocketClosedUnexpectedlyError while awaiting #initiator results in multiple connecting sockets / connections #2443
Comments
The best bug report I've seen in a long time! Great job! :) I think that your solution (using |
@leibale Is there a plan for this fix? |
@TrevorNodeJS I'm on vacation, I'll fix it when I'm back... |
@niksy umm no.. the issue here is that an error in the client "initiator" (which is the function that runs between the "connect" and "ready" event and is in charge of setting all the connection level config like Regarding your situation - if the errors are only when the client is idling - usually it's the server that closes idle connections (I'm pretty sure that it's on by default on Azure and AWS). You can workaround that using the |
Oh, okay, maybe that could help. Do you know if node-redis v3 had some built-in pinging ability with specified value? |
@niksy No, but you can always use setInterval(() => {
client.ping(err => {
if (err) {
// ...
}
});
}, 1000 * 60 * 4); |
For anyone looking for solution to this error message, set More information: https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-best-practices-connection#idle-timeout |
Description
Hello, we noticed in our logs that node-redis was able to get into a broken state during a ongoing networking issue causing socket closures. The last logs from some machines were the "Socket closed unexpectedly" error message, with no follow up reconnect event. We also noticed that some machines were firing multiple connecting / reconnecting events in parallel for the same client.
I believe there is an issue in error handling when a socket is closed during the #initiator promise in #connect.
On that line, the state of socket is:
Looking at createSocket:
And finally looking at #onSocketError
So we see that the socket close event will cause this.#connect to be called again, even though we are in the middle of connecting to begin with.
A potential solution would be to check #isReady in onSocketError to know whether we are already in the process of connecting or not.
Node.js Version
lts/gallium
Redis Server Version
No response
Node Redis Version
4.3.1, but source taken from 4.6.5
Platform
linux
Logs
The text was updated successfully, but these errors were encountered: