Skip to content
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

Disconnected web socket connection to backend is not detected #17409

Closed
3 tasks done
leonardmgh opened this issue Jul 26, 2023 · 11 comments
Closed
3 tasks done

Disconnected web socket connection to backend is not detected #17409

leonardmgh opened this issue Jul 26, 2023 · 11 comments
Labels

Comments

@leonardmgh
Copy link
Contributor

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

I am using an IPad Pro as dashboard for HomeAssistant. After it has been running with the HomeAssistant App / Safari open for a few hours the frontend disconnects completely from the backend. Inspecting it i can see that the frontend still thinks that it has a open websocket to the HomeAssistant backend. Looking in the logs i can see that the web sockets usually has been disconnected hours ago on the backend side. I have been able to reproduce the same problem on a MacBook Pro M1 in Safari.

Now i have finally been able to reproduce the error by going out of the app and changing the wifi network. I am not sure if the device changing wifi networks in the background has been the cause of the problem the whole time or just one way to trigger it.

Describe the behavior you expected

The frontend should detect that the websocket connection to the backend is dead and create a new connection.

Steps to reproduce the issue

IPad with HomeAssistant accessed over local network:

  1. Open HomeAssistant(App or Browser)
  2. Exit App(don't close it)
  3. Go to wifi settings and change network.
  4. (You can now connect to the old wifi network again)
  5. Open HomeAssistant again
  6. Now all buttons "work", but commands are never received on backend.

What version of Home Assistant Core has the issue?

Home Assistant 2023.7.1

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Safari/605.1.15

Which operating system are you using to run this browser?

IPadOS 16.6

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

Inspecting the websocket connection when problem occurs. (Look at the timestamps)
https://pasteboard.co/JEbFwovEslEm.png

@leonardmgh
Copy link
Contributor Author

leonardmgh commented Jul 26, 2023

Its seems like webkit in general is unreliable to detect a broken websocket connection. Besides that did i also read about @karwosts having the same (or similar) issue when his PC wakes up from sleep.

As far as i can see its only the backend that pings the frontend. So my thought for a potential workaround/solution for issues where the websocket disconnects could be a timeout in the frontend received from the backend for some time. Or maybe just pinging the backend from the frontend. However i could imagine this could have some other unforeseen side effects.

@leonardmgh
Copy link
Contributor Author

In home-assistant/iOS#2219 the same issue is discussed. According to this comment
home-assistant/iOS#2219 (comment) the connection should error out at some point. From what i have seen however this never occurs.

Also i have found other similar issues, that might be caused by something else, but result in the same state of the HA frontend.
home-assistant/iOS#1801
home-assistant/core#57271

@WSchnee
Copy link

WSchnee commented Sep 2, 2023

Can confirm this.

I have two iPads (Pro1, 2017), as well as iPhones (SE 1, 6). They are wall mounted controllers with the display ‘always on’. When this happens a pull-down to refresh on all the devices is required to restore the connection, which seems to time out on a sporadic basis.

I am using the iOS App on all those devices.
Furthermore, no WIFI/Network outage was recorded on my network when this happened. Neither were any automatic updates run on the devices during this time It seems to just timeout after some time.

Copy link

github-actions bot commented Dec 1, 2023

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 1, 2023
@WSchnee
Copy link

WSchnee commented Dec 1, 2023

This is still a problem.

@github-actions github-actions bot removed the stale label Dec 1, 2023
@leonardmgh
Copy link
Contributor Author

dev...leonardmgh:homeass-frontend:fix-halfopen-websocket
Something like this will probably fix it. I haven't tested it though.

@xuefer
Copy link

xuefer commented Dec 6, 2023

dev...leonardmgh:homeass-frontend:fix-halfopen-websocket Something like this will probably fix it. I haven't tested it though.

an active ping is exactly the fix as I suggested before i find this issue. please make it important priority. stability is required by screens that show home assistant as main and only UI. opening frontend for "manual" usage from time to time, is not "smart" way. any manual usage is not smart enough

@leonardmgh leonardmgh mentioned this issue Dec 6, 2023
9 tasks
@leonardmgh
Copy link
Contributor Author

leonardmgh commented Dec 17, 2023

dev...leonardmgh:homeass-frontend:fix-halfopen-websocket Something like this will probably fix it. I haven't tested it though.

an active ping is exactly the fix as I suggested before i find this issue. please make it important priority. stability is required by screens that show home assistant as main and only UI. opening frontend for "manual" usage from time to time, is not "smart" way. any manual usage is not smart enough

You are welcome to review my PR and give some feedback :) #18934

@xuefer
Copy link

xuefer commented Dec 18, 2023

the patch works for me, it should be merged and polished later

Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 17, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2024
@leonardmgh
Copy link
Contributor Author

Should be fixed with #18934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants