2

I have a simple node application which handles GET /foo. This request takes some time to compute and return a file. Each time the request lasts more than 2 minutes, the connection is closed. I'm using Express 4.10.2 and node 0.10.32.

I read that http module has a default timeout of 2 minutes: http://contourline.wordpress.com/2011/03/30/preventing-server-timeout-in-node-js/

I tried to use:

server.on('connection', function(socket) {
    socket.setTimeout(5*60*1000); //5 minutes
});

But even if the connection is not closed after two minutes, when the server tried to send the file back, I got:

{ [Error: Request aborted] code: 'ECONNABORT' }

EDIT:

server.setTimeout(5*60*1000); works fine! Thanks @mscdex

kdelemme
  • 333
  • 1
  • 7
  • 20

1 Answers1

2

server.setTimeout() is the method that sets the HTTP connection timeout for all connections.

mscdex
  • 104,356
  • 15
  • 192
  • 153