Nodejs and express server closes connection after 2 minutes

前端 未结 3 1030
[愿得一人]
[愿得一人] 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:09

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

    The 2 minutes are default.

    UPDATED ANSWER

    Try this:

    var express = require('express');
    var http = require('http');
    
    var app = module.exports.app = express();
    var server = http.createServer(app);
    server.setTimeout(10*60*1000); // 10 * 60 seconds * 1000 msecs
    server.listen(appConfig.port, function () {
        var logger = app.get('logger');
        logger.info('**** STARTING SERVER ****');
    });

    Or this:

    http.request(url).setTimeout()
    

    Also, it can be a browser issue. Read this.

提交回复
热议问题