Pergunta

I have an app with Node.js, Express.js, and Socket.io that runs fine using ANY port except 443. The server is meant to only operate over HTTPS port 443 and likewise, the websocket should be 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 right away with an error:

warn: error raised: Error: listen EADDRINUSE
Foi útil?

Solução

Apparently you've already got a server listening on that port on your machine. Is is possible that you started this server elsewhere and it's still running?

Outras dicas

It means that the port is in use, you can check using : sudo netstat -tapen | grep ":443". If you use Apache, Ngnix or other server it is likely to be it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top