diff --git a/editor/js/comms.js b/editor/js/comms.js
index ac726d3de..6edd9afa0 100644
--- a/editor/js/comms.js
+++ b/editor/js/comms.js
@@ -18,7 +18,8 @@ RED.comms = (function() {
var errornotification = null;
var clearErrorTimer = null;
-
+ var connectCountdownTimer = null;
+ var connectCountdown = 10;
var subscriptions = {};
var ws;
var pendingAuth = false;
@@ -82,14 +83,39 @@ RED.comms = (function() {
}
};
ws.onclose = function() {
- if (reconnectAttempts > 5 && errornotification == null) {
- errornotification = RED.notify(RED._("notification.error",{message:RED._("notification.errors.lostConnection")}),"error",true);
- } else if (clearErrorTimer) {
+ if (clearErrorTimer) {
clearTimeout(clearErrorTimer);
clearErrorTimer = null;
}
reconnectAttempts++;
- setTimeout(connectWS,1000);
+ if (reconnectAttempts < 10) {
+ setTimeout(connectWS,1000);
+ if (reconnectAttempts > 5 && errornotification == null) {
+ errornotification = RED.notify(RED._("notification.errors.lostConnection"),"error",true);
+ }
+ } else if (reconnectAttempts < 20) {
+ setTimeout(connectWS,2000);
+ } else {
+ connectCountdown = 60;
+ connectCountdownTimer = setInterval(function() {
+ connectCountdown--;
+ if (connectCountdown === 0) {
+ errornotification.update(RED._("notification.errors.lostConnection"));
+ clearInterval(connectCountdownTimer);
+ connectWS();
+ } else {
+ var msg = RED._("notification.errors.lostConnectionReconnect",{time: connectCountdown})+' '+ RED._("notification.errors.lostConnectionTry")+'';
+ errornotification.update(msg);
+ $(errornotification).find("a").click(function(e) {
+ e.preventDefault();
+ errornotification.update(RED._("notification.errors.lostConnection"));
+ clearInterval(connectCountdownTimer);
+ connectWS();
+ })
+ }
+ },1000);
+ }
+
}
}
diff --git a/editor/js/ui/notifications.js b/editor/js/ui/notifications.js
index 809fcec51..f64bf6f89 100644
--- a/editor/js/ui/notifications.js
+++ b/editor/js/ui/notifications.js
@@ -48,6 +48,14 @@ RED.notify = (function() {
});
};
})();
+
+ n.update = (function() {
+ var nn = n;
+ return function(msg) {
+ nn.innerHTML = msg;
+ }
+ })();
+
if (!fixed) {
$(n).click((function() {
var nn = n;
diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json
index ce2d7a0e1..c8c4e95ea 100644
--- a/red/api/locales/en-US/editor.json
+++ b/red/api/locales/en-US/editor.json
@@ -59,7 +59,9 @@
"error": "Error: __message__",
"errors": {
- "lostConnection": "Lost connection to server",
+ "lostConnection": "Lost connection to server, reconnecting...",
+ "lostConnectionReconnect": "Lost connection to server, reconnecting in __time__s.",
+ "lostConnectionTry": "Try now",
"cannotAddSubflowToItself": "Cannot add subflow to itself",
"cannotAddCircularReference": "Cannot add subflow - circular reference detected"
}