Hi Everyone,
I am making this multiplayer online game playable via the browser and its heavily dependent on websockets.
I am using phoenix channels at the backend and react js as the front end.
I am facing this issue where the channel connection often suffers from errors for unknown reasons.
The onError callback for phoenix channels js client is executed often around every 5~10min. I am not sure why this happens.
Currently, I am doing nothing in the onError callback just logging to console hopping that it will reconnect.
gameChannel.onError((e) => {
console.log('An error occured on game channel ', e);
});
however this error leads to issues in the UI since on the server I have some logic which executes when player disconnects.
I have the backend deployed on gigalixir, there are no errors on the backend channel. This problem also happens some times when I run the backend server locally so I am not sure wether its due to gigalixir.
Can someone help me on why this happens, possible cause behind the on error callback getting triggered and any fixes?
My assumption is it happens maybe because the browser drops the websocket connection occasionally due to some reason, maybe when the user has minimized the browser or its not in focus or due to some issue with react, the socket and channel is stored in a react state.
Its pretty random and hard to debug the root cause, any help would be great, this is the last issue that I need to fix everything else seems to work.























