Search code examples
node.jsexpresskeep-alive

Why my node js express app not keep alive?


I have a node js app use express that get video from youtube and response to the client, I use Litespeed Server, my server is enabled 'keep-alive', when I run my code from localhost, it works great and the response include 'Connection: Keep-Alive' in it's header and the whole file is downloaded.

But when I deployed to the server,the response doesn't include 'Connection: Keep-Alive' in it's header and it always stop after download 10MB. It make me stucked and feel bad about this, so anyone can give me some solution ?

This is my code to get file and response to client :

res.writeHead(200, {"Connection": "keep-alive","Content-Type": "video/mp4", "Content-disposition": "attachment; filename=abc.mp4"});
request(inputUrl).pipe(res);

Solution

  • The root cause is in the configuration file httpd_config.xml of Litespeed Webserver have this configuration : maxDynRespSize 10M, it makes the response to stop after transferring 10MB , I modified it to 1000M and the issue is gone.