peerjs-server
peerjs-server copied to clipboard
Cannot create PeerJS Server on Port 443
My server has an SSL certificate, and the domain works fine with https. I ran "npm install peer", and then ran this javascript:
const { PeerServer } = require('peer');
const peerServer = PeerServer({
port: 9000,
path: '/myapp'
});
It worked, but only under http, and if secure:false. This URL returned the correct JSON: http://www.mydomain.com:9000/myapp
I then removed the 'port 9000' PeerJS server, and ran this javascript so it would hopefully work with secure:true:
const { PeerServer } = require('peer');
const peerServer = PeerServer({
port: 443,
ssl: {
key: fs.readFileSync('my.key'),
cert: fs.readFileSync('my.crt')
},
path: '/myapp2'
});
This did not work. The following URL returned a blank directory, and no JSON: https://www.mydomain.com:443/myapp2
My server is running CentOS v. 7.8 64 bit, and it uses httpd.
Let me know if it will be easier to configure a port that is not "well-known" (i.e. not 443) to use for https communication with the PeerJS Server, so I can set "secure: true" in the client script.
hey did you able to use it on any other server other than localhost ? I need help .please
This could be because ports below 1024 require superuser access. Perhaps try running the node server as superuser and see if it works?
Since running node as superuser is bad practice, you can configure firewalld / iptables to forward packets from port 443 to 9000. That way, you can run node on port 9000 without superuser and receive all packets that are sent to port 443 (for SSL).
I don't have this problem with either port configuration of 443 or 4430 for https. But I have another error:
websocket.js:88 WebSocket connection to 'wss://localhost:4430/socket.io/?EIO=4&transport=websocket&sid=o8iBr3NIfoDIaANAAAAA' failed:
and with port 443:
websocket.js:88 WebSocket connection to 'wss://localhost/socket.io/?EIO=4&transport=websocket&sid=GIzVOZeoSyroFUPCAAAA' failed:
I will open an issue with it and list the code that doesn't have this error, may be it will help you there.