Hi

Im new to node.js and having problems getting a proper connection
handling to work. As far as I understand for every request the method
http.createServer() is called.

Within this function I add a request-handler for close and end.

req.connection.addListener('close', function () {
  clearInterval(sendData);
  res.end();
});
req.connection.addListener('end', function () {
  clearInterval(sendData);
  res.end();
});

Afterwards I set the response header and send data like a ping every 2
seconds like this:

res.writeHead(200, noCacheHeaders);
sendData = setInterval(function()
{
  currentTime = new Date();
  res.write('\n')
}, res_interval);

When I start a request now it works, when I end it (pressing escape)
most of them are cancelled and the close and end handlers are called.
But if I start a few more and cancel them some requests seem never to
realize the close or end event and keep sending data forever.

Can somebody help me to fix the problem?

Thanks.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to