diff --git a/public/javascripts/messaging.js b/public/javascripts/messaging.js index f0977a40c..3e8948174 100644 --- a/public/javascripts/messaging.js +++ b/public/javascripts/messaging.js @@ -39,9 +39,11 @@ const messaging = (function() { } function connectWebSocket() { + const protocol = document.location.protocol === 'https:' ? 'wss' : 'ws'; + // use wss for secure messaging - ws = new WebSocket("ws://" + location.host); - ws.onopen = function (event) {}; + ws = new WebSocket(protocol + "://" + location.host); + ws.onopen = event => console.log("Connected to server with WebSocket"); ws.onmessage = messageHandler; ws.onclose = function(){ // Try to reconnect in 5 seconds