I'm trying to implement an http long polling server in Node.js, and have no idea how to close/shutdown pending requests if a timeout is reached.
3 possible solutions come to my mind:
Both solutions don't seem very reasonable, so what would be the Node.js way to achieve something like this?
Why don't those sound reasonable? In particular, setting a timeout on the socket seems to make sense to me, as:
end
/destroy
on the socket)I would probably go this route so that Node handles the timeout behind the scenes; however, if it makes sense for your app, I don't see any harm in keeping a timestamp and expiring connections manually.
You may be interested in these articles, each of which handles expiring connections differently:
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