Reputation: 16693
I am trying to use webRTC
to stream audio from a client to Node.js.
The problem is: webRTC
does not work on HTTP, only HTTPS. So - My IIS is using this port. I tried establishing my Node.js to listen to port 443:
Node.JS script:
var options = {
key: fs.readFileSync('../cert/key.pem'),
cert: fs.readFileSync('../cert/server.crt')
};
var httpsserver = https.createServer(options).listen(443);
var server = binaryServer({ server: httpsserver, port: 443 });
Client script:
client = new BinaryClient('ws://example.com:443');
I'm getting this error in my node script, so my first question is: Is this because port 443 is being used by my IIS?
throw er; // Unhandled 'error' event ^
Error: listen EACCES 0.0.0.0:443 at Object.exports._errnoException (util.js:1018:11) at exports._exceptionWithHostPort (util.js:1041:20) at Server._listen2 (net.js:1249:19)
Having this error, I tried using a different port (9001).
Client script:
client = new BinaryClient('ws://example.com:9001');
When I try to connect from a client to the node.js server on 9001, because the site address is https://example.com
, I'm getting this error in the client:
Mixed Content: The page at 'https://example.com/page.aspx' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://example.com:9001/'. This request has been blocked; this endpoint must be available over WSS.
Because the error mentions using wss://
, I tried the following.
So, I switch the client to work with WSS://
,
client = new BinaryClient('wss://example.com:9001');
but then, in the client, I get this error:
WebSocket connection to 'wss://example.com:9001/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED
Any ideas how can I run my node.js server on a srcure port, assuming my IIS uses port 443, and still be able to connect securly to a client, and use webRTC ?
Upvotes: 0
Views: 1747
Reputation: 2643
Chrome is allowing gUM/WebRTC from Secure origins only, i.e: page url should be https & all the subsequent requests from that page should be secure.
So we must use wss:// as websocket url
It seems you are using self signed certificates, Allow the certificate manually by entering the URL https://example.com:9001 in browser tab.
After opening the page you should get an error page, then you need to allow by clicking Advanced -> proceed.
If the page is not loaded, then u need to look into firewall or ip/dns of your server is reachable from the browser.
Upvotes: 1
Reputation: 111444
If you already have a web server running and serving secure requests then what is usually done is having that web server act as a reverse proxy for you Node application. That way you don't need to handle the certificates and you don't worry about port conflicts.
See this answers and links for more details:
Upvotes: 0