diff --git a/modules/websocket_util.py b/modules/websocket_util.py
index 187a3486a626cd2485c8888af715278bde170294..17007da807d36fb403c22338bf10e0460175b69a 100644
--- a/modules/websocket_util.py
+++ b/modules/websocket_util.py
@@ -7,4 +7,9 @@ def WEBSOCKET_SEND(_room, _type, _data):
     websocket_send('http://127.0.0.1:8888', _data, '67c371fd204fbcbf9742310d1a9d951bcca1aa86', _room.code)
 
 def GET_URL(_room):
-    return("ws://"+GET_HOST()+":8888/realtime/"+_room.code)
+    if current.request.env.wsgi_url_scheme == "https":
+        protocol = "wss"
+    else:
+        protocol = "ws"
+
+    return(protocol+"://"+GET_HOST()+":8888/realtime/"+_room.code)
diff --git a/views/game/index.html b/views/game/index.html
index 535a5e53e19ac3ab66fd3aecd361b555171d16b8..cb2bf400e50ceb5a246a7e06ca1fc5fbdefb3250 100644
--- a/views/game/index.html
+++ b/views/game/index.html
@@ -32,14 +32,14 @@
         if ('WebSocket' in window) {
             var ws = new WebSocket("{{=GET_URL(room_record)}}");
             ws.onopen = function () {};
-            ws.onmessage = function(e){
+            ws.onmessage = function(e) {
                 set_info(e.data);
                 render(name, role, JSON.parse(e.data));
             };
             ws.onerror = function(e) {
                 set_error("{{=T('Error')}}: "+e);
             };
-            ws.onclose =function () {
+            ws.onclose = function () {
                 set_error("{{=T('WebSocket has closed')}}. {{=T('Please refresh this website')}}.");
             };
         } else {