diagnosis of the reconnection problem not receiving events

This commit is contained in:
talksik
2022-05-09 05:45:39 -05:00
parent 65acb2411b
commit b2bbc2ed35
@@ -35,29 +35,30 @@ function useSocketHandler(linesData: MasterLineData[]) {
/** /**
* handle ws connection * handle ws connection
*/ */
// ! POTENTIAL DIAGNOSIS with socket reconnections on electron idle causing
// no more event listeners being fired off: potentially because the listeners were for an older manager or instance
// so when the client reconnects, with another instance,
useEffect(() => { useEffect(() => {
$ws = io("http://localhost:5000", { $ws = io("http://localhost:5000", {
query: { token: jwtToken }, query: { token: jwtToken },
transports: ["websocket"],
upgrade: false,
forceNew: true,
reconnection: false, // ! TESTING THE PROBLEM WITH RECONNECTION CLIENT LISTENERS NOT ACTIVATING
}); });
$ws.on("connect", () => toast.success("you are connected")); $ws.on("connect", () => {
console.log(
// client-side errors "SOCKETS | CLIENT CONNECTED in socket handler, setting up client side listeners for requests"
$ws.on("connect_error", (err) => { );
console.error(err.message); // prints the message associated with the error toast.success("you are connected");
toast.error("sorry...this is our bad...please refresh with cmd + r");
// force refetch of server status as well as these generally go hand in hand
// this should overall remount this component currently which is what we want for new data
queryClient.invalidateQueries("SERVER_CHECK");
});
}, []);
/** /**
* initiate listeners * initiate listeners
*/ */
useEffect(() => {
/** /**
* TODO: P0 : notified that someone else added me to a line they created * TODO: P0 : notified that someone else added me to a line they created
*/ */
@@ -190,7 +191,28 @@ function useSocketHandler(linesData: MasterLineData[]) {
}); });
} }
); );
}, [setLinesMap]); });
$ws.io.on("close", () => {
console.error(
"there was a problem with your app...connection closed likely due to idling"
);
toast.error(
"SOCKETS | connection closed with websockets!!!! either reload app or manually reconnect here"
);
});
// client-side errors
$ws.on("connect_error", (err) => {
console.error(`SOCKETS | ${err.message}`); // prints the message associated with the error
toast.error("sorry...this is our bad...please refresh with cmd + r");
// force refetch of server status as well as these generally go hand in hand
// this should overall remount this component currently which is what we want for new data
queryClient.invalidateQueries("SERVER_CHECK");
});
}, []);
/** handle initial data coming in and creating the initial line map /** handle initial data coming in and creating the initial line map
* and doing initial connections/tune ins ?could trigger this later? * and doing initial connections/tune ins ?could trigger this later?