Search code examples
node.jssocketstream

SocketStream - Detect when client disconnect from server side


Is there a way to detect when a client disconnect from the server side?

app.js

ss.event.on("close",function(session){

console.log(client disconnected); });

thanks


Solution

  • Check these two:

    req.on("close", function() {
      // request closed unexpectedly
    });
    
    req.on("end", function() {
      // request ended normally
    }):