我有一个套接字应用程序,我试图在端口 443 (https) 上进行监听。如果我更改端口(例如 8080),我不会遇到任何问题。
显示的错误是
error raised: Error: listen EACCES
我的应用程序源代码是:
var fs = require('fs');
// create the https server and listen on port
var options = {
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('server.key')
};
var server = require('https').createServer(options);
var portNo = 443;
var app = server.listen(portNo, function() {
console.log((new Date()) + " Server is listening on port " + portNo);
});
// create the socket server on the port
var io = require('socket.io').listen(app);
// This callback function is called every time a socket
// tries to connect to the server
io.sockets.on('connection', function (socket) {
console.log((new Date()) + ' Connection established.');
// When a user send a SDP message
// broadcast to all users in the room
socket.on('message', function (message) {
socket.broadcast.emit('message', message);
});
// When the user hangs up
// broadcast bye signal to all users in the room
socket.on('disconnect', function () {
// close user connection
console.log((new Date()) + " Peer disconnected.");
socket.broadcast.emit('user disconnected');
});
});
我已经看到很多与 Linux 相关的答案告诉他们以 sudo 身份运行,所以我尝试以管理员身份运行节点服务器,但无济于事。
这是在 Windows Server 2012 机器上运行的。
谢谢。