Fix: web console: prevent concurrent websockets

This commit is contained in:
Bernhard Kirchen
2025-02-04 20:25:55 +01:00
committed by Thomas Basler
parent 2d412a0928
commit 3934284a6f

View File

@@ -106,16 +106,17 @@ export default defineComponent({
this.closeSocket();
};
},
// Send heartbeat packets regularly * 59s Send a heartbeat
// Send heartbeat packets regularly * 5s Send a heartbeat
heartCheck() {
if (this.heartInterval) {
clearTimeout(this.heartInterval);
clearInterval(this.heartInterval);
}
this.heartInterval = setInterval(() => {
if (this.socket.readyState === 1) {
if (this.socket.readyState === WebSocket.OPEN) {
// Connection status
this.socket.send('ping');
} else {
clearInterval(this.heartInterval);
this.initSocket(); // Breakpoint reconnection 5 Time
}
}, 5 * 1000);
@@ -129,7 +130,7 @@ export default defineComponent({
}
if (this.heartInterval) {
clearTimeout(this.heartInterval);
clearInterval(this.heartInterval);
}
},
getOutDate(): string {