0

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.

Community
  • 1
  • 1
Saman Mohamadi
  • 4,454
  • 4
  • 38
  • 58

1 Answers1

-1

First, check winston daily rotate file, they have a transport for logging unhandled exceptions. Second, if after sometime your app becomes slow, it is possible that you have a memory leak because the garbage collection slows the process or the thread gets blocked by a long running synchronus code, it will be helpful if you show your code here.

Yuri Khomyakov
  • 370
  • 2
  • 9