浏览代码

Merge pull request #959 from zauberzeug/websocket_first

try websocket first and use long polling only as fallback
Falko Schindler 2 年之前
父节点
当前提交
58840d843d
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      nicegui/templates/index.html

+ 2 - 1
nicegui/templates/index.html

@@ -155,8 +155,9 @@
           const query = { client_id: "{{ client_id }}" };
           const url = window.location.protocol === 'https:' ? 'wss://' : 'ws://' + window.location.host;
           const extraHeaders = {{ socket_io_js_extra_headers | safe }};
+          const transports = ['websocket', 'polling'];
           window.path_prefix = "{{ prefix | safe }}";
-          window.socket = io(url, { path: "{{ prefix | safe }}/_nicegui_ws/socket.io", query, extraHeaders });
+          window.socket = io(url, { path: "{{ prefix | safe }}/_nicegui_ws/socket.io", query, extraHeaders, transports });
           window.socket.on("connect", () => {
             window.socket.emit("handshake", (ok) => {
               if (!ok) window.location.reload();