node-server-screenshot icon indicating copy to clipboard operation
node-server-screenshot copied to clipboard

Doesn't seem to be working on nginx server

Open abhighyaa-jain opened this issue 4 years ago • 2 comments

I just tried to deploy a small script which took screenshot of google.com. When tested on local machine, everything is working perfectly. however once deployed the image is not formed and it returns 504 gateway timeout.

(Read show: false suggestion for heroku app -> that did not work too :( )

Any suggestions ?

abhighyaa-jain avatar May 07 '20 13:05 abhighyaa-jain

I will assume that you have deployed your code as a service with an nginx reverse proxy in front of it.

Since the error code you're getting is 504 gateway timeout (i assume from nginx) it means that your service fails to respond within the configured timeout of nginx upstream proxy call. This may be caused by many things, here are a couple off the top of my head:

  1. the service crashes and hangs the HTTP request from nginx
  2. the upstream connection is slow (unlikely you can't load google.com in 60 seconds)
  3. your VM/machine performance is inadequate and cannot start/sustain a chromium instance 3.1) if your machine is good enough to run a chromium instance but not more, make sure you only generate one screenshot at a time, since each call will require another chromium instance.

If none of the above fit your case, i'll need more details about your setup

legraphista avatar May 07 '20 15:05 legraphista

I further checked the server logs and found this error -

upstream prematurely closed connection while reading response header from upstream

which means my node server is closing the connection when the library is encountered.

abhighyaa-jain avatar May 08 '20 08:05 abhighyaa-jain