-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recover from broken websocket connection #403
Conversation
Hi @LeHaTrifork It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
1 similar comment
Hi @LeHaTrifork It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Hi @leonardmgh It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
I don't think that this belongs in HAWS. This can be added to the frontend if it's necessary. The frontend already has a lot of mechanisms for this, and if those don't fully work, they need to be fixed. It's also very inefficient to clear the timer on every message. We receive a lot of messages. That's creating/clearing a lot of timers. Better to check from time to time if it's still connected. |
Fair enough, i was also a bit split on where to implement this mechanism. Currently (20230705.1) the mechanisms in the frontend don't work for my scenario. In general i think it's needed to implement a pinging mechanism to the backend, since the reported state of the websocket by the browser can be unreliable and this would catch 100% of the scenarios. Regarding my implementation, i can see that the clearing of timers is inefficient. My intention was to only ping the backend when it's really necessary to avoid messing with the connection and causing unwanted behaviour when the connection actually is active. But i think i just overcomplicated things here. |
Also, where would in your opinion be the best place to implement this functionality in the frontend? @balloob |
@balloob Why was this issue closed? I feel we need a solution to this, as it would solve this issue, along with a bunch of others, right? |
As described here: home-assistant/frontend#17409 the HA frontend sometimes ends up with a broken web-socket connection to the backend. No error disconnect even/error is ever thrown. To work around this i have implemented a polling mechanism from the backend to the frontend.
The frontend sends a ping message to the backend after it hasn't received any messages for 60 seconds with a 5 second timeout and forces the socket to close if no response is recieved.