fix: Explicitly set keep-alive server timeout
MODIFY
lib/express/server.js
lib/express/server.js
@@ -18,6 +18,9 @@ import B from 'bluebird';
import { DEFAULT_BASE_PATH } from '../protocol';
+const KEEP_ALIVE_TIMEOUT_MS = 60 * 10 * 1000; // 10 minutes
+
+
async function server (opts = {}) {
const {
routeConfiguringFunction,
@@ -60,7 +63,7 @@ async function server (opts = {}) {
reject(err);
});
httpServer.on('connection', (socket) => {
- socket.setTimeout(600 * 1000); // 10 minute timeout
+ socket.setTimeout(KEEP_ALIVE_TIMEOUT_MS);
socket.on('error', reject);
});
configureServer(app, routeConfiguringFunction, allowCors, basePath);
@@ -77,6 +80,9 @@ async function server (opts = {}) {
}
resolve(httpServer);
});
+ httpServer.keepAliveTimeout = KEEP_ALIVE_TIMEOUT_MS;
+ // headers timeout must be greater than keepAliveTimeout
+ httpServer.headersTimeout = KEEP_ALIVE_TIMEOUT_MS + 5 * 1000;
});
}

fix: Explicitly set keep-alive server timeout (#366)