Set the time limits for how long a connection can be in an idle state or open. The connection will be closed if it doesn't send data within the given time.
const http = require('http');
const server = http.createServer((req, res) => {
res.end('Hi , there !');
});
// Set the timeout for inactive sockets in milliseconds
server.timeout = 4000; // 4 seconds
server.listen(5000, () => {
console.log('Server is listening on port 5000');
});