I am writing a proxy app in nodejs which handles thousands of concurrent connections inwards and outwards
I want to make sure all idle and unneeded connections get closed properly and their file descriptors get released. If it leaks file descriptors, I would run out of them very fast.
My question is that :
what is the best solution to make sure a connection gets closed ? socket.end() or socket.destroy() ?
Currently I am using socket.end() but in doc it says it half closes the connection, is there a situation that socket.end() doesn't result in closing a connection ? what I am interested in is releasing the file descriptors ASAP.
So what do you suggest ?
socket.end() is a much better way to gracefully terminate your connections. socket.destroy terminates all of your connections immediately. Also, due to a bug, in most of the cases one had to add socket.end after destroy to make it work.
So end() is the way to go!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With