@@ -344,8 +344,6 @@ def _instance(self):
344344 runtimeInstances [str (id (self ))] = self
345345 clients [self .session ] = self
346346
347- websocket_type = 'ws' if self .server .ssl_version == None else 'wss'
348-
349347 net_interface_ip = self .headers .get ('Host' , "%s:%s" % (self .connection .getsockname ()[0 ],self .server .server_address [1 ]))
350348
351349 websocket_timeout_timer_ms = str (self .server .websocket_timeout_timer_ms )
@@ -389,8 +387,13 @@ def _instance(self):
389387 };
390388
391389 function openSocket(){
390+ ws_wss = "ws";
391+ try{
392+ ws_wss = document.location.protocol.startsWith('https')?'wss':'ws';
393+ }catch(ex){}
394+
392395 try{
393- ws = new WebSocket('%(websocket_type)s ://%(host)s/');
396+ ws = new WebSocket(ws_wss + ' ://%(host)s/');
394397 console.debug('opening websocket');
395398 ws.onopen = websocketOnOpen;
396399 ws.onmessage = websocketOnMessage;
@@ -586,8 +589,7 @@ def _instance(self):
586589 fd.append('upload_file', file);
587590 xhr.send(fd);
588591 };
589- </script>""" % {'websocket_type' :websocket_type ,
590- 'host' :net_interface_ip ,
592+ </script>""" % {'host' :net_interface_ip ,
591593 'max_pending_messages' :pending_messages_queue_length ,
592594 'messaging_timeout' :websocket_timeout_timer_ms }
593595
0 commit comments