Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close HTTP connection in node.js using Express

I use node.js (Express) with server-sent events. I would like to close the event stream by closing the sse HTTP connection. Given the folllwing function:

router.get('/sse', function (req, res) {

});

how can this be achieved?

like image 954
ps-aux Avatar asked Apr 17 '16 18:04

ps-aux


1 Answers

use this

res.end();

and it will work to close connection

like image 120
Muhammad F. Musad Avatar answered Sep 19 '22 18:09

Muhammad F. Musad