Dear all
i've got an http cluster based on nodejs, basically this component does the
following:
- does some regex matching on the req.url
- case A) -> forward the request to a back-end
- case B) -> check if exists a local file
- case B.KO) -> forward the request to a back-end
- case B.OK) -> pipe the local file to the request
this component handles about 100 req/sec, but i've noticed that an average
of 2/1000 requests in case B.OK doesn't close and remains in a undefined
state without throwing events
This is the code:
kcache.stats.totalcounter++;
var readStream = fs.createReadStream(file_path_data);
readStream.on('error', function(err) {
kcache.stats.errorscounter++;
});
readStream.on('end', function(err) {
kcache.stats.completedcounter++;
});
readStream.on('open', function () {
if (acceptEncoding.match(/\bdeflate\b/)) {
res.setHeader('content-encoding', 'deflate');
return readStream.pipe(zlib.createDeflate()).pipe(res);
} else if (acceptEncoding.match(/\bgzip\b/)) {
res.setHeader('content-encoding', 'gzip');
return readStream.pipe(zlib.createGzip()).pipe(res);
} else {
return readStream.pipe(res);
}
});
After some minutes of working, i expect that the "processing" requests
should be
kcache.stats.totalcounter - (kcache.stats.errorscounter +
kcache.stats.completedcounter)
But this number continues to grow, seeming that the readStream object
doesn't throw any error/end event.
Maybe i should set up a timeout or an inactivity event ? is possible to do
that?
Thanks
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/ebcf465c-2b8c-47e0-a363-e8e61935ee82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.