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 ?
To disable, just use “KeepAlive Off”. It sets the maximum number of requests for every Keep-Alive connection. A value of 100 is normally good enough for almost any scenario. This value, however, should be increased depending on the amount of files within a web page that the server is supposed to deliver.
Keep-Alive is enabled by default in most cases, however, sometimes hosting companies disable Keep-Alive for performance reasons. If HTTP Keep-Alive isn't enabled, you can enable it using the following options.
Try something like: app. use( session( { secret: 'keyboard cat', cookie: { maxAge: 60000 }, rolling: true, resave: true, saveUninitialized: false } ) );
Enabling Keep-Alive ensures that a single TCP connection is used to transfer multiple files from the server to the browser. This helps your page load faster as the browser doesn't need to establish multiple connections to retrieve all your page resources.
Although not ideal, setting the Connection
header to close
in a middleware can help you.
Express.js close response
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With