-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
TCP Keep-Alive - ECONNRESET #1939
Comments
There are two ways to call the Node.js set keep alive on the socket (https://nodejs.org/dist/latest-v9.x/docs/api/net.html#net_socket_setkeepalive_enable_initialdelay):
|
Ha! Great! Thank you very much :) |
just wanted to confirm your suggestion works perfectly. Thanks again for the help :) |
@odubuc May I ask, are you making queries through a single connection or are you utilizing pooled connections? My assumption is the former as I don't know if it's possible to As of now, I have implemented the May I also ask what load balancer you are using? I am using HAProxy with Docker Swarm and having my node application communicate with MySQL over the Docker overlay network. When my app is left idle for ~15 minutes, my subsequent requests can take as long as 100 seconds. These queries all normally take less than a second so I am guessing all the surplus goes into reconnecting. So far no timeouts for 1 hour of idleness, fingers crossed this holds up! |
@st3xupery sorry for the delay, I totally missed your message. I'm using a pool of connection but it is a home made implementation and not the pool contained in this library. But to answer your question, yes, at the initialization of the pool, I initialise all the connections to have their own 60 seconds keep-alive The load balancer is in Azure so it's the "Azure Loadbalancer" which close any idle sockets (configurable from 4 minutes to 30 minutes). A little background:
The behavior I was seeing: Now that all the connections in the pool got their own keep-alive, not a single one gets killed by the load balancer so no more hanging |
You can alter new connection objects as the pool creates them in the |
Much thanks @odubuc and @dougwilson , your help has been immensely useful. |
Hi,
My application is going through a load balancer that kills inactive TCP sockets after a few minutes.
This makes my application wait until the 'timeout' setting until it realise the connection is probably at fault.
Is it possible to add a heartbeat configuration to keep the TCP connection alive forever ?
The text was updated successfully, but these errors were encountered: