From 46d9e6fb983fbec09cb5f6d22ef95918042ad28f Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Sun, 11 Sep 2022 17:57:58 +0800 Subject: [PATCH] Add more log in case of disconnection --- src/contexts/HttpQueueContext.js | 5 ++++- src/contexts/WsContext.js | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/contexts/HttpQueueContext.js b/src/contexts/HttpQueueContext.js index c3ea16889..1bc054b8b 100644 --- a/src/contexts/HttpQueueContext.js +++ b/src/contexts/HttpQueueContext.js @@ -24,6 +24,8 @@ import { useWsContext } from "./WsContext" import { useTargetContext } from "../targets" let counterNoAnswer = 0 +const MaxNoAnswerNb = 4 + /* * Local const * @@ -105,7 +107,8 @@ const HttpQueueContextProvider = ({ children }) => { } else { if (!e.code) { counterNoAnswer++ - if (counterNoAnswer > 3) { + console.log("Connection lost ?", counterNoAnswer) + if (counterNoAnswer > MaxNoAnswerNb) { Disconnect("connectionlost") } } diff --git a/src/contexts/WsContext.js b/src/contexts/WsContext.js index 29e11a2a3..abde02250 100644 --- a/src/contexts/WsContext.js +++ b/src/contexts/WsContext.js @@ -170,8 +170,12 @@ const WsContextProvider = ({ children }) => { //seems sometimes it disconnect so wait 3s and reconnect //if it is not a log off if (!isLogOff.current) { - if (!isPingPaused) reconnectCounter.current++ + if (!isPingPaused) { + reconnectCounter.current++ + console.log("reconnecting ", reconnectCounter.current) + } if (reconnectCounter.current >= maxReconnections) { + console.log("Reconnection over ", maxReconnections) Disconnect("connectionlost") } else { console.log("Ws connection lost")