node.js - Streaming large files causing server to hang -


i have feature in web app allows users upload , download files. serve app express, files stored in different server, proxy requests server. here's proxy code using request library:

module.exports = function(req, res) {     req.headers['x-private-id'] = getid();      var url = rewriteurl(req.url);      var newrequest = request(url, function(error) {         if (error) console.log(error);     });      req.pipe(newrequest).on('response', function(res) {         delete res.headers['x-private-id'];     }).pipe(res); }; 

this works fine of requests, including downloading file. however, run issues when 'streaming' file. , streaming, mean use fancybox display video using video tag. video displays fine first few times.

but if close fancybox , reopen enough times (5 specifically), quits working after that; video no longer shows up. entire express server seems hang, unable process more requests. if restart server, ok. me seems sockets proxy requests aren't being closed properly, can't figure out why. there wrong proxy code?

you need either increase pool.maxsockets value passed in request() config since defaults node's http agent's maxsockets 5, or opt out of connection pooling altogether pool: false in request() config.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -