6

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 ?

Marco Salerno
  • 5,131
  • 2
  • 12
  • 32
Asmaa Djo
  • 85
  • 1
  • 9
  • Set the `keepAliveTimeout` configuration option on the http server instance. [See the docs](https://nodejs.org/api/http.html#http_server_keepalivetimeout). – Robert Rossmann Oct 06 '17 at 16:54
  • @RobertRossmann I already tried to, but it doesnt work since it's linked to express app – Asmaa Djo Oct 09 '17 at 09:45

1 Answers1

2

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

Express.js close response

Ati Ranzuglia
  • 318
  • 1
  • 12