Hello everyone.
(Sorry, my English is poor)
I made a HTTP server.
I am using "HTML5 Server-Sent Events"
[http://dev.w3.org/html5/eventsource/] on the server to push notifications.
Under the conditions, when a HTTP client was hung-up, then the HTTP server
is hung-up!
Flow is below:
1. The client application hang-up.
2. The server is sending push-notifications periodically.
3. The receiving buffer of the socket for the client application becomes
full.
4. The sending buffer of the socket in the server becomes full.
5. The writing queue of the socket in Nodejs is been increasing
unlimited.
6. Becomes to low memory at the server!
I have considered that check the writing queue of the socket in Nodejs
before writing push-notifications, and close the socket.
function writeUpdateEvent(res, data) {
if (res.socket._pendingWriteReqs > 1000) {
logger.warn('TCP Socket is TOO BUSY!!');
res.end();
}
else {
res.write('id: ' + data.id + '\n');
res.write('event: update\n');
res.write('data: ' + JSON.stringify(data) + '\n\n');
}
}
But, the code has used two undocumented properties:
- http.ServerResponse.socket
- net.Socket._pendingWriteReqs
What should I do better solutions?
Or this way is right?
Thanks.
Toru Nagashima (長島 徹).
--
--
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
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.