Node.js + Express.js + Socket.io on port 443 (HTTPS TLS / SSL)

I have an application with Node.js, Express.js and Socket.io that works fine using ANY port other than 443. The server is designed to work only through the HTTPS 443 port, and also so that the websocket is encrypted as well.

CODE THAT WORKS

var fs = require('fs');
var https = require('https');
var express = require('express');
var socket = require('socket.io');
var sslOptions = {
    key: fs.readFileSync(__dirname + '/../ssl/server.key,
    cert: fs.readFileSync(__dirname + '/../ssl/server.pem,
    ciphers: 'ECDHE-RSA-AES256-SHA:AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM',
    honorCipherOrder: true
};

var app = express();
var server = https.createServer(sslOptions, app);
var io = socket.listen(server, {
    "log level" : 3,
    "match origin protocol" : true,
    "transports" : ['websocket']
});
server.listen(8443);

When I change the port (last line) to 443, the Node server crashes immediately with an error:

warn: error raised: Error: listen EADDRINUSE
+2
source share
2 answers

Apparently, you already have a server that is listening on this port on your computer. Is it possible that you started this server elsewhere and it still works?

+1
source

, , , : sudo netstat -tapen | grep ": 443". Apache, Ngnix , , , .

+1

All Articles