16
votes

I have configured the Websocket on my live server and I'm using SSL on live server. When I used following code on my localhost, websockets were fine.

ws://localhost:8080/server.php

Once I moved the file to the live server I have changed the code to the following

wss://IP:PORT/server.php

I have created a seperate port for web socket and configured on firewall TCP IN and OUT. However, I'm receiving the following error on console

WebSocket connection to ............ failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

Can anyone suggest me some solutions to overcome this issue

2
If you just moved the setup to a live server it does not get automatically SSL enabled (i.e. wss:// vs. ws://). What makes you think that wss:// should work?Steffen Ullrich
@SteffenUllrich This is my first attempt on Websocket. I'm not much familiar with WS. That's why seeking help hereuser3818758

2 Answers

9
votes

Basically when you are using wss you are just serving the WebWocket over SSL/TLS.

Meanwhile using a simple ws does not require a particular setup, wss does. Indeed you have to create a secure connection using a valid SSL Certificate when opening the communication.

If you certificate is missing or invalid the connection cannot be enstabilished therefore an error will be raised while attempting to start the communication.

So you can't just switch from ws to wss but also have to make a proper implementation.

You can find more details here, hope that helps!

1
votes

here is what I did, I never able to install ssl in local, so I started using the w3cwebsocket client

https://www.npmjs.com/package/websocket

and test it in console using

 node index.js

var W3CWebSocket = require('websocket').w3cwebsocket; var client = new W3CWebSocket('wss://127.0.0.1:7000/'); console.log(client)