简体   繁体   中英

Node.js: Express.js set keep-alive

What is the correct way for set keep alive in express.js web server?

I have found some examples..

Example n. 1 :

var express = require('express');
var app = express();
var server = app.listen(5001);

server.on('connection', function(socket) {
  socket.setTimeout(30 * 1000);
});

Example n. 2 :

var express = require('express');
var app = express();
var server = app.listen(5001);
server.keepAliveTimeout = 30 * 1000;

set server.headersTimeout with a value higher than server.keepAliveTimeout . ( check this solution for a similar issue and this page out)

example code:

var express = require('express');
var app = express();
var server = app.listen(5001);
server.keepAliveTimeout = 30 * 1000;
server.headersTimeout = 35 * 1000;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM