put timeout settings when creating the server

This commit is contained in:
Girish Ramakrishnan
2023-04-05 11:05:31 +02:00
parent 61b7dfa58c
commit c9f0f300a6

View File

@@ -25,7 +25,8 @@ let gHttpServer = null;
async function initializeExpressSync() {
const app = express();
const httpServer = http.createServer(app);
// server socket "idle" timeout is 0 by default. we use the timeout middleware to handle timeouts on a route level
const httpServer = http.createServer({ headersTimeout: 60000, requestTimeout: 1000 * 60 * 60 }, app); // see also nginx client_header_timeout (30s)
const wsServer = new ws.Server({ noServer: true }); // in noServer mode, we have to handle 'upgrade' and call handleUpgrade
@@ -378,11 +379,6 @@ async function initializeExpressSync() {
// OpenID connect sessions
router.del ('/api/v1/oidc/sessions', token, authorizeUser, routes.oidc.destroyUserSession);
// disable server socket "idle" timeout. we use the timeout middleware to handle timeouts on a route level
// we rely on nginx for timeouts on the TCP level (see client_header_timeout)
httpServer.setTimeout(0);
httpServer.requestTimeout = 1000 * 60 * 60; // this value changed in node 18 to 5 mins
// upgrade handler
httpServer.on('upgrade', function (req, socket, head) {
// create a node response object for express