简体   繁体   中英

What is difference between keepAliveTimeout and connection timeout. How can I check keepAliveTimeout in headers?

Is there any difference between keepAliveTimeout and connection timeout ? I am using node.js with express. I have specified timeout as follows:

const app = express();
app.listen(3000, '0.0.0.0', () => {
  console.log(`The server is running at http://localhost:3000/`);
});
app.on('connection', (socket) => {
  socket.setTimeout(60 * 1000);
});

Will above code change keepAliveTimeout ? In browser I am getting just Connection: keep-alive header in browser. How can I check keepAliveTimeout of my application ?

Keep-Alive header can inform the client how long the server is willing to keep the connection open (timeout=N value) and how many requests you can do over the same connection (max=M) before the server will force a close of the connection.

Connection-TimeOut is when you request for connect and that takes mintue and don't get response so it give you Connection-TimeOut

You can set the parameters like this,

const server = app.listen(port, () => {
   console.log(`server on port ${port}`);
});
server.keepAliveTimeout = 65000;
server.headersTimeout = 66000;

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