添加连接失败重连

master
夜笙歌 2 years ago
parent 6e86463fcd
commit 9844bc76ea

@ -646,20 +646,20 @@ export default {
alert("您的浏览器不支持Websocket通信协议") alert("您的浏览器不支持Websocket通信协议")
return return
} }
let url = "ws://10.11.41.249:8080/websocket/message"; //
let websocket = null;//WebSocket const getWebsocket = () => {
let lockReconnect = false; // let websocket = new WebSocket("ws://10.11.41.249:8080/websocket/message")
let wsCreateHandler = null; //
websocket = new WebSocket(url)
websocket.onopen = function (event) { websocket.onopen = function (event) {
console.log("服务已连接") console.log("服务已连接")
}; };
websocket.onmessage = function (event) { websocket.onmessage = function (event) {
console.log(event) console.log(event)
} }
websocket.onerror = function (event) {
setTimeout(getWebsocket,1000)
};
}
getWebsocket()
} }
} }
} }

Loading…
Cancel
Save