From 28bc44391466a7e59590731d29e5c1716b530e06 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 3 Dec 2017 10:12:16 -0500 Subject: [PATCH] using WSS protocol when on HTTPS instead of WS --- public/javascripts/messaging.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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