Hello,
I moved my app from http to https and realised I needed to make changes to my peer server for it to be able to connect. I realised, as mentioned here:
https://github.com/peers/peerjs-server that I need to add in the security cert and key to the server script, so I now have an index.js as such:
var fs = require('fs');
var ip = require('ip');
var PeerServer = require('peer').PeerServer;
var port = 9000;
var server = new PeerServer({port: port, allow_discovery: true});
var server = PeerServer({
port: port,
ssl: {
key: fs.readFileSync('/path to key.key'),
cert: fs.readFileSync('/path to cetificate.crt')
},
allow_discovery: true
});
server.on('connection', function (id) {
console.log('new connection with id ' + id);
});
server.on('disconnect', function (id) {
console.log('disconnect with id ' + id);
});
console.log('peer server running on ' +
ip.address() + ':' + port);
But I am getting this error when trying to run the server:
peer server running on
172.31.46.6:9000events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::9000
at Object.exports._errnoException (util.js:907:11)
at exports._exceptionWithHostPort (util.js:930:20)
at Server._listen2 (net.js:1250:14)
at listen (net.js:1286:10)
at Server.listen (net.js:1382:5)
at PeerServer (/home/ubuntu/www/UH_Web/node_modules/peer/lib/index.js:90:12)
at Object.<anonymous> (/home/ubuntu/www/UH_Web/server/index.js:7:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
It will then shutdown automatically. This is something going quite deep into peer script and I'm completely new to SSL so it is baffling my mind. It seems to be unhappy with the port, but it worked perfectly on http....
Any ideas?