After first time reconnect (retries = 1), and recived a "http-status 500" (or 503, 404 ...), neffos would no try any more reconnect .
file: /src/neffos.js
line : 993:
let check = (): void => {
// Note:
// We do not fire a try immediately after the disconnection as most developers will expect.
_fetch(endpointHTTP, fetchOptions).then(() => {
notifyOnline(tries);
}).catch(() => { // on network failures.
// if (err !== undefined && err.toString() !== "TypeError: Failed to fetch") {
// console.log(err);
// }
tries++;
setTimeout(() => {
check();
}, checkEvery)
});
};
This would not catch any bad http-status. the new code :
let check = (): void => {
// Note:
// We do not fire a try immediately after the disconnection as most developers will expect.
_fetch(endpointHTTP, fetchOptions).then((response) => { // <--- on response
if (response.ok) { // on response ok
notifyOnline(tries);
} else {
return Promise.reject(`${response.status}:${response.statusText}`) // <-- reject
}
}).catch((err) => { // on network failures.
// if (err !== undefined && err.toString() !== "TypeError: Failed to fetch") {
// console.log(err);
// }
tries++;
setTimeout(() => {
check();
}, checkEvery)
});
};
Now, even if the ws-server is restarted after a long time, the ws-client (mneffos.js) can reconnect normally.
After first time reconnect (retries = 1), and recived a "http-status 500" (or 503, 404 ...), neffos would no try any more reconnect .
file: /src/neffos.js line : 993:
This would not catch any bad http-status. the new code :
Now, even if the ws-server is restarted after a long time, the ws-client (mneffos.js) can reconnect normally.