添加连接失败重连

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

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

Loading…
Cancel
Save