diff --git a/src/main/webapp/js/globalConstant.js b/src/main/webapp/js/globalConstant.js index c17313984f7539c909b6b3fee4292eea35c8b047..3a1f4a034e3d8576622a789326fe0bbdb3c94dd2 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;