I am trying to do a basic websocket example. It works correctly when I use an insecure connection, but I cannot even connect to the server using wss. The site is secured using GoDaddy which I believe is already loaded as a trusted CA. Is there anything else I need to do? I'm using ws://echo.websocket.org and wss://echo.websocket.org which just echo whatever message you send.
console.log("Trying to open websocket"); webSocket = new WebSocket(webSocketUrl); /* If the connection is established */ webSocket.onopen = function(e) { console.log('connection open, readyState: ' + e.target.readyState); var box2 = document.querySelector('#textbox2'); box2.innerHTML = "open"; }; /* If the connection fails or is closed with prejudice */ webSocket.onerror = function(e) { /* Error handling */ console.log('connection error: ' + e); var box3 = document.querySelector('#textbox3'); box3.innerHTML = 'connection error: ' + e; }; webSocket.onmessage = function(e) { console.log('server message: ' + e.data); var box4 = document.querySelector('#textbox4'); box4.innerHTML = 'server message: ' + e.data; };
For the insecure case I see that the socket opens and later send and receive messages. For the secure case neither the open or onerror methods are called.