diff --git a/documentation/samples/src/main/resources/assets/socket.js b/documentation/samples/src/main/resources/assets/socket.js
index <HASH>..<HASH> 100644
--- a/documentation/samples/src/main/resources/assets/socket.js
+++ b/documentation/samples/src/main/resources/assets/socket.js
@@ -27,7 +27,10 @@
         if (window.WebSocket) {
             // Compute the web socket url.
             // window.location.host includes the port
-            var url = "ws://" + window.location.host + "/ws/websocket";
+            var url =  "ws://" + window.location.host + "/ws/websocket";
+            if (window.location.protocol == "https:") {
+                url =  "wss://" + window.location.host + "/ws/websocket";
+            }
             socket = new WebSocket(url);
             socket.onopen = onopen;
             socket.onmessage = onmessage;
Compute the right web socket url

wss:// is used when the page is loaded with https://