Domanda

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
È stato utile?

Soluzione

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?

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top