Connection to WebSocket on wss failed

I bought a certificate and installed it on my node.js. website But https in the browser is displayed in green and in order. Now I am trying to establish a socket connection using wss, but this failed. The client-side error in Javascript is as follows.

WebSocket connection to 'wss://securedsitedotcom:3003/call' failed: WebSocket opening handshake was canceled 

Please, help!

Client Side Code (Javascript)

 var ws = new WebSocket('wss://securedsitedotcom:3003/call'); 

Server Side Code (node.js)

  https = require('https'); var server = https.createServer({ key: fs.readFileSync(config.certKeyPath), cert: fs.readFileSync(config.certCrt), requestCert: true, rejectUnauthorized: false },app); server.listen(port); var wss = new ws.Server({ server: server, path: '/call' }); 

Error in browser console:

 WebSocket connection to 'wss://securedsitedotcom:3003/call' failed: WebSocket opening handshake was canceled 
+6
source share
2 answers

Recent work with Chrome has shown that if a page is used as https in Chrome, websites should use wss. And if wss needs to be used, port 443 must be used (and I didn’t download any other secure port, and so far I have not seen any way to change the port), which may be your problem, since your port looks like 3003 above.

Now I'm trying to get my IT group to patch / update Apache on this server, so mod_proxy_wstunnel can be used so that Apache listens on the 443 reverse proxy server and sends all the wss traffic to my websocket server.

Hope this helps.

+2
source

I had a similar problem, but I used a self-signed certificate. You mentioned that you have acquired a certificate. I am a guest, he is signed by a certification body.

Otherwise, as in my case, an unaudited certificate may lead to the error "the opening of the handshake is canceled." The verified certificate is either verified by a third party (a certification authority, i.e. VeriSign), or explicitly authorized by the client.

In my case, VeriSign did not sign my certificate (signed itself), so I had to explicitly allow it. To do this, I just need to visit the https URL with a browser (in your case, " https: // securedsitedotcom: 3003 / call "). Then a “warning unauthorized host” appears. You must allow the exception, and you can make your WSS connection.

Your server can use any port, it is not tied to 443. 443 is the default port for https, but any port can be explicitly specified as you did.

I hope this helps someone.

+2
source

All Articles