From 8f2ab2a7dabb32b46687e196da632f933261315f Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Fri, 6 Dec 2019 09:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/js/globalConstant.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/js/globalConstant.js b/src/main/webapp/js/globalConstant.js index c173139..3a1f4a0 100644 --- a/src/main/webapp/js/globalConstant.js +++ b/src/main/webapp/js/globalConstant.js @@ -630,17 +630,21 @@ function createWebSocket (path) { if (top.homeUrl == null || top.homeUrl == '') { return null; } - let url = (top.homeUrl).replace('https', 'ws').replace('http', 'ws'); - let ws; - if ('WebSocket' in window){ - ws = new WebSocket(url + path); - } - else if ('MozWebSocket' in window){ - ws = new MozWebSocket(url + path); - } - else{ - console.error("该浏览器不支持websocket"); - return null; + let url = (top.homeUrl).replace('https', 'wss').replace('http', 'ws'); + let ws = null; + try { + if ('WebSocket' in window){ + ws = new WebSocket(url + path); + } + else if ('MozWebSocket' in window){ + ws = new MozWebSocket(url + path); + } + else{ + console.error("该浏览器不支持websocket"); + return null; + } + } catch (err) { + console.error(err); } return ws; -- Gitee