--- a/svghmi/svghmi.js Thu Nov 17 11:08:36 2022 +0100
+++ b/svghmi/svghmi.js Fri Nov 18 10:40:57 2022 +0100
@@ -607,6 +607,7 @@
var periodic_reconnect_timer;
+var force_reconnect = false; // Once connection established
function ws_onopen(evt) {
@@ -617,6 +618,7 @@
window.clearTimeout(periodic_reconnect_timer);
periodic_reconnect_timer = window.setTimeout(() => {
+ force_reconnect = true; periodic_reconnect_timer = null;
@@ -635,17 +637,16 @@
function ws_onclose(evt) {
console.log("Connection closed. code:"+evt.code+" reason:"+evt.reason+" wasClean:"+evt.wasClean+" Reload in "+reconnect_delay+"ms.");
- // TODO : add visible notification while waiting for reload
- console.log(evt.wasClean)
- console.log(evt.reason)
- // Do not attempt to reconnect immediately in case of Normal Closure
+ // Do not attempt to reconnect immediately in case: + // - connection was closed by server (PLC stop) + // - connection was closed locally with an intention to reconnect + if(evt.code=1000 && !force_reconnect){ window.alert("Connection closed by server");
window.setTimeout(create_ws, reconnect_delay);
+ force_reconnect = false;