What is the procedure to change ws into wss?
Whether wss is make upgrade over normal HTTP or wss works only HTTPS?
webSocket = new WebSocket("ws://localhost:port/Esv/ocp");
works fine, when I changed ws to wss
webSocket = new WebSocket("wss://localhost:port/Esv/ocp");
it shows this error:
Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
Short version
To SSL or not SSL
You may have a SSL certificate issue. The connection point rule can be summarized as:
wss
connects onhttps only
ws
connects onhttp
and vice-versa:
https
acceptswss only
http
acceptsws only
Errors
Following situations will lead you to an error (tests done under Firefox):
wss
connection to ahttp
endpoint. In my tests, I had anws
connection to ahttps
endpoint, you'll have the errorFormal answer
The bible of websocket is RFC 6455. In section 4.1.5:
The secure flag is defined by the URI. Section 3 defines what is secure
TL;DR
If you want to use
wss
:https://...
): "security downgrade" is not allowedIf you want to use
ws
:http://...
)