Skip to content

Build your personal knowledge base with Trilium Notes

using WSS protocol when on HTTPS instead of WS

azivner28bc44391466
diff --git a/public/javascripts/messaging.js b/public/javascripts/messaging.js
index f0977a40cc..3e8948174a 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