0
votes

I tried to simply get locations of photos in my route and render product.ejs file:

 //Show individual product info
router.get('/product/:id', async function(req, res, next) {
  let filesFromFolder;

  Promise.all([
    database.retreaveImage(req.params.id)
  ]).then(resultArr => {
    filesFromFolder = resultArr[0];


    res.render('product.ejs', {
      productName: req.params.id,
      data: filesFromFolder

    });
  });
});

It works on localhost, now i importet my route.js file in real server, and when i try to open product it throws 504 error.

tried to follow this instructions but no help.

Getting 504 GATEWAY_TIMEOUT NodeJs

grep -i "504" /var/log/nginx/access.log

82.135.208.60 - - [16/Sep/2019:07:52:25 +0000] "GET /product/line_fan_pool HTTP/1.1" 504 594 "http://13.58.120.242:3000/horizontal" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" 82.135.208.60 - - [16/Sep/2019:08:03:15 +0000] "GET /product/line_pool HTTP/1.1" 504 594 "http://13.58.120.242:3000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" 82.135.208.60 - - [16/Sep/2019:08:10:19 +0000] "GET /product/line_pool HTTP/1.1" 504 594 "http://13.58.120.242:3000/" "Mozilla/5.0 (Linux; Android 6.0; Nexus 5Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36"

2
Is this behind an nginx proxy? What does the proxy say about this? Do you see anything in the logs? Also, can you test some site not requiring database access to narrow down the possible causes?g_bor
Other sites works good only this one throws 504.I updated question with some more infoEmilis

2 Answers

0
votes

Problem was that, amazon web server did not support old version of MYsql so i had to update it. That solved my problem. Had to watch in pm2 monit for error.

0
votes

I experienced a 504 in my node expressjs app when something broke inside my http-proxy-middleware.

It was a Promise error not catched and so the server silently timedout into the 504 instead of reporting the error.

So never forget to catch your Promises when they fall. (Is this what happened here?)

 //Show individual product info
router.get('/product/:id', async function(req, res, next) {
  let filesFromFolder;

  Promise.all([
    database.retreaveImage(req.params.id)
  ]).then(resultArr => {
     //...
  }).catch(err => next); // catch and burn.
});