Reputation: 557
I am using express with node.js for a http server. I store the response object so I can stream events down to the client on that channel. Is there a way to detect when the client disconnects? When I kill my client I can still write to the response object without getting any kind of exception/error. It looks like the service keeps the underlying tcp channel open as long as I keep writing to the response object.
Upvotes: 24
Views: 23448
Reputation: 169383
req.on("close", function() {
// request closed unexpectedly
});
req.on("end", function() {
// request ended normally
});
Upvotes: 54