I have managed to just get websockets working on my server. i have a page Document that connects to a nodejs app located on ws.trivia.house.
when i switch to use wss at Document the service fails althouh i have a letencrypt certificate covering wildcard of *trivia.house and covering ws.trivia.house. can someone help me please?
the failure is:
WebSocket connection to 'wss://ws.trivia.house:8080/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
My domain is:
trivia.house
(websocket subdomain) ws.trivia.house
Are you trying to use the same socket port for both secure and insecure connections?
Are all these ports accessible from the Internet?
How do you test?
I only want to use the socket for secure connections but yes it can be used for both i believe - i didnt realise there was a difference as its the connecting protocol that differs not the js app. should it be using a different port?
The socket app is only running on port 8080 and yes it is accessible.
If you go to Document and use the inspect function to see console you will see success
Do the same for Document and you will see failures.
I'm not that familiar with WebSockets, but indeed, that does look problematic.
Maybe you can explain a little bit more about how you've set up that WebSockets service. I'm assuming Node.js (ugh..) from your initial post? But how exactly?
Hi all thanks for all the replies. I should have been a little clearer.. I was only using unsecure sockets whilst i set up now i only want to use secure so staying on port 8080 should be ok. You can ignore the 'ws' version.
For context, it is a js file that creates the socket server running on nodejs.
the code in the js app is:
var WebSocket = require('ws');
var server = new WebSocket.Server({port: 8080});
console.log('Listening on port 8080...');
server.on('connection', function(socket) {
console.log('Client has connected');
socket.on('message', function(message) {
console.log('Received from client: %s', message);
socket.send('Server received message from client: ' + message);
});
});
Well, you claim nginx is using the same file for key and cert, so obviously you've looked at something, right? Something with ssl_certificate and (optional) ssl_certificate_key.