Asmaa Djo
Asmaa Djo

Reputation: 95

How to disable keep-alive in node server

I am developing an application backend based on node.js server and express, the application is receiving an external flux from an apache server that require a "keep alive " disabled

So I tried to disable the option buy req.setSocketKeepAlive(false);

var http = require('http');
var express = require('express');

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
var app = express();
var server = http.createServer(app);
server.keepAliveTimeout(0)

but it doesnt work.

Do you have any ideas how to solve this issue ?

Upvotes: 7

Views: 6044

Answers (1)

Ati Ranzuglia
Ati Ranzuglia

Reputation: 348

Although not ideal, setting the Connection header to close in a middleware can help you.

Express.js close response

Upvotes: 3

Related Questions