Skip to content

Commit

Permalink
Add more log in case of disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Sep 11, 2022
1 parent 02d5f55 commit 46d9e6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/contexts/HttpQueueContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { useWsContext } from "./WsContext"
import { useTargetContext } from "../targets"

let counterNoAnswer = 0
const MaxNoAnswerNb = 4

/*
* Local const
*
Expand Down Expand Up @@ -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")
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/contexts/WsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 46d9e6f

Please sign in to comment.