I am getting 504 GATEWAY_TIMEOUT
http response after 60s of page loading.
It is not an actual page that is being loaded, than rather a process that is being executed. I am expecting it to take longer than 60s and I've tried to increase the timeout value, but it didn't help.
I am using express framework for routing and I host the job on EB (AWS Elastic Beanstalk). Since I have increased all timeout values that I could possibly find on EB and Load Balancers in AWS console, I assume it must be the app itself that has timeout set to 60s. However, I might be wrong.
My code:
/* GET home page. */
router.get('/main',function(req, res, next) {
req.connection.setTimeout(600000);
mainProcess(res);
//res.send("mainProcess() called");
});
UPDATE:
Besides this, I've tried a different approach. I added this code to the app.js
:
var connectTimeout = require('connect-timeout');
var longTimeout = connectTimeout({ time: 600000 });
app.use(longTimeout);
Didn't help either.
UPDATE2:
I have also tried increasing the timeout in /bin/www
like this:
var server = http.createServer(app);
server.timeout=600000;
UPDATE3:
I have noticed that the timeout is related to the nginx configuration. As my logs say: upstream timed out (110: Connection timed out) while reading response header
However, I can't figure out a way to edit nginx config on Elastic beanstalk. I did some research, but it all seems non standard to me and too rigid for such simple thing.
var timeout = require('connect-timeout'); app.post('/test', timeout('6s'), function(req, res, next) {console.log('test')})
– Fernando Zamperinapp.post
anywhere. The express framework did it differently. There is onlyapp.use('/', routes);
– Ondrej Tokar/* GET home page. */ var timeout = require('connect-timeout'); router.get('/main', timeout('6s'), function(req, res, next) { mainProcess(res); //res.send("mainProcess() called"); });
– Fernando Zamperinlocation / { proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_connect_timeout 60s; //Here is where you put the timeout }
– Fernando Zamperin