How to modify the nodejs request default timeout time?

前端 未结 6 1922
南旧
南旧 2020-11-27 17:05

I\'m using a Node/express server. The default timeout of express is 120,000 ms, but it is not enough for me. When my response reaches 120,000 ms, the console will log

6条回答
  •  粉色の甜心
    2020-11-27 17:36

    Linking to express issue #3330

    You may set the timeout either globally for entire server:

    var server = app.listen();
    server.setTimeout(500000);
    

    or just for specific route:

    app.post('/xxx', function (req, res) {
       req.setTimeout(500000);
    });
    

提交回复
热议问题