mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Make the comms link be more tolerant to temporarily blips
This commit is contained in:
parent
f9fb97adf2
commit
da64c018ac
@ -22,6 +22,7 @@ RED.comms = (function() {
|
|||||||
var subscriptions = {};
|
var subscriptions = {};
|
||||||
var ws;
|
var ws;
|
||||||
var pendingAuth = false;
|
var pendingAuth = false;
|
||||||
|
var reconnectAttempts = 0;
|
||||||
|
|
||||||
function connectWS() {
|
function connectWS() {
|
||||||
var path = location.hostname;
|
var path = location.hostname;
|
||||||
@ -46,6 +47,7 @@ RED.comms = (function() {
|
|||||||
|
|
||||||
ws = new WebSocket(path);
|
ws = new WebSocket(path);
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
|
reconnectAttempts = 0;
|
||||||
if (errornotification) {
|
if (errornotification) {
|
||||||
clearErrorTimer = setTimeout(function() {
|
clearErrorTimer = setTimeout(function() {
|
||||||
errornotification.close();
|
errornotification.close();
|
||||||
@ -80,12 +82,13 @@ RED.comms = (function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
if (errornotification == null) {
|
if (reconnectAttempts > 5 && errornotification == null) {
|
||||||
errornotification = RED.notify(RED._("notification.error",{message:RED._("notification.errors.lostConnection")}),"error",true);
|
errornotification = RED.notify(RED._("notification.error",{message:RED._("notification.errors.lostConnection")}),"error",true);
|
||||||
} else if (clearErrorTimer) {
|
} else if (clearErrorTimer) {
|
||||||
clearTimeout(clearErrorTimer);
|
clearTimeout(clearErrorTimer);
|
||||||
clearErrorTimer = null;
|
clearErrorTimer = null;
|
||||||
}
|
}
|
||||||
|
reconnectAttempts++;
|
||||||
setTimeout(connectWS,1000);
|
setTimeout(connectWS,1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user