Hello,
Using the built-in http and https packages causes a memory leak when the server gets flooded with requests from different IPs which eventually crashes the server.
Code
const express = require('express');
const fs = require('fs');
const http = require('http');
const https = require('https');
const app = express();
app.enable('trust proxy');
app.all('*', (req, res) => {
return res.send({
message: 'Hello World!'
});
});
const privateKey = fs.readFileSync('/etc/letsencrypt/live/.../privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/.../cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/.../chain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate,
ca: ca
};
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);
httpServer.listen(80, () => {
console.log('HTTP Server running on port 80');
});
httpsServer.listen(443, () => {
console.log('HTTPS Server running on port 443');
});
Error
(node:14043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
Hello,
Using the built-in
httpandhttpspackages causes a memory leak when the server gets flooded with requests from different IPs which eventually crashes the server.Code
Error