Ensure WS ping interval is cleared onclose.
@@ -94,7 +94,7 @@ window.GoAccess = window.GoAccess || {
},
setWebSocket: function (wsConn) {
- var host = null;
+ var host = null, pingId = null;
host = wsConn.url ? wsConn.url : window.location.hostname ? window.location.hostname : "localhost";
var str = /^(wss?:\/\/)?[^\/]+:[0-9]{1,5}\//.test(host + "/") ? host : String(host + ':' + wsConn.port);
str = !/^wss?:\/\//i.test(str) ? (window.location.protocol === "https:" ? 'wss://' : 'ws://') + str : str;
@@ -104,7 +104,7 @@ window.GoAccess = window.GoAccess || {
this.currDelay = this.wsDelay;
if (wsConn.ping_interval) {
- setInterval(() => {
+ pingId = setInterval(() => {
socket.send('ping');
}, wsConn.ping_interval * 1000);
}
@@ -120,6 +120,7 @@ window.GoAccess = window.GoAccess || {
socket.onclose = function (event) {
GoAccess.Nav.WSClose();
+ window.clearInterval(pingId);
socket = null;
setTimeout(() => { this.reconnect(wsConn); }, this.currDelay);
}.bind(this);
