I'm working on a website based on expressjs which streams videos and users can download video files from it.
when I start the app, everything works well. But after some while app can not stream videos and downloading files doesn't work too(it returns an empty file after a long delay) the only way to fix it is to restart the app.
nginx error log:
2017/01/16 19:39:39 [error] 10584#10584: *23717 upstream prematurely closed connection while reading upstream, client: x.x.x.x, server: example.com, request: "GET /api/course/.../video/.../stream HTTP/1.1", upstream: "http://127.0.0.1:8080/api/course/.../video/.../stream", host: "example.com"
I use pm2 in cluster mode .
I have this in the app for logging errors:
process.on('uncaughtException', function(err) {
console.log(err);
winston.error('Caught exception : ' ,err);
});
But there is no error in log files.
for streaming video I use an approach similar to this .
for downloading files I use express download function.