node.js http server, detect when clients disconnect

前端 未结 1 907
攒了一身酷
攒了一身酷 2021-02-05 07:52

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 clien

1条回答
  •  忘掉有多难
    2021-02-05 08:38

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

    0 讨论(0)
提交回复
热议问题