undefinedfix
Sign in

The node server opens two HTTPS ports and gets stuck after a period of time?

Jsn edited in Fri, 25 Nov 2022

I use node to start two services on the same server, but after a period of time, a large amount of internal memory will get stuck, and then I can't restart the server. I have to close an HTTPS service to work. What's the situation? The specific code is as follows

Open a var httpserver= http.createServer (app); var httpsServer = https.createServer ({ key:fs.readFileSync ( path.join (__ dirname, './123.key'), 'utf8'), cert:fs.readFileSync ( path.join (__ dirname, './123.crt'), 'utf8') }, app);var PORT = 80; var SSLPORT = 443; httpServer.listen (PORT, function() { console.log ('HTTP Server is running on: http://localhost :%s', PORT); }); httpsServer.listen (SSLPORT, function() { console.log ('HTTPS Server is running on: https://localhost :%s', SSLPORT); });

Open two

var privateKey = fs.readFileSync ( path.join (__ dirname, './key/123.key'), 'utf8'); var certificate = fs.readFileSync ( path.join (__ dirname, './key/123.crt'), 'utf8'); var credentials = {key: privateKey, cert: certificate};var httpsServer = https.createServer (credentials, app); httpsServer.listen (8000, function() { console.log ('HTTPS Server is running on: https://localhost :%s', 8000);})

0 Replies