Nodejs and express server closes connection after 2 minutes

前端 未结 3 1054
[愿得一人]
[愿得一人] 2021-01-02 07:29

Im using Express 4.X and node js 0.12.

One of my routes is for file uploading and processing and for some of the files the upload and process takes more than the 2 m

3条回答
  •  爱一瞬间的悲伤
    2021-01-02 08:26

    After a few hours of trying every answer available I had run an inspection with fiddler for that request. Turns out that in my development environment im using browser-sync for auto refreshing the browser window on any change. In fiddler i noticed that a long with the upload POST request browser-sync tied it to a socket connection which had 2 minute timeout.

    after switched off the browser-sync proxy the very first solution worked like a charm.

    server.on('connection', function(socket) {
      socket.setTimeout(600 * 60 * 1000); // now works perfectly...
    })
    

提交回复
热议问题