iOS icon indicating copy to clipboard operation
iOS copied to clipboard

Frontend does not re-establish connection and/or refresh screen even though connection & local push works

Open eigenphase opened this issue 5 months ago • 16 comments

iOS device model, version and app version

Model Name: iPad Pro (10.5-inch) Software Version: 17.3.1 App version: 2025.1305

Home Assistant Core Version

2025.8.2

Describe the bug

This is related and a followup to https://github.com/home-assistant/iOS/issues/3735. That bug got closed but for a different reason and honestly, I think the underlying issue is a different one (than the new screen that was introduced).

Setup: Wall-mounted iPad Pro with latest HA app. The app is locked into "Guided Access" mode. After a few minutes of inactivity, the tablet turns off. A motion sensor is used to send a notification to the tablet which wakes up the tablet and shows HA. This is a well known implementation of wall tablet in iOS (e.g., [1]).

The tablet itself is 1-2m from a hardwired access point and the signal strength and stability is superior. HA is connected via internal URL and Local Push is enabled.

What happens: Usually this works well, even over hours. But sometimes, the app "looses connection" and is stuck with the message "Connection lost. Reconnecting ..." (see screenshot below). Sometimes this is succeeded by the full screen message described in https://github.com/home-assistant/iOS/issues/3735 (which prompted my first report). However, I can confirm that the network connection is flawless (I can ping the tablet from HA in the background) and when I tap into the app settings, I immediately see the status that app is connected via Internal URL, WebSocket is connected and Local Push is "Available (5)".

Furthermore, when I pull down the screen it refreshes and connection immediately works again.

In other words: The connection itself is not the issue. Connectivity is completely local and perfect.

This behavior completely destroys the user experience of the wall tablet.

I feel this was working flawlessly in the past but kept becoming an issue more recently. I also thought it might be related to my complex dashboards, so I tested with a very simple dashboard but the issue remained.

Expected behavior

I am not sure how the communication between HA server and app works exactly but from user perspective, one of the following must the case:

  1. Either the app needs to ensure it remains connected to the server. If, for whatever reason, the connection fails, the app has to re-establish the connection, rather than waiting for the user to refresh
  2. Another option is to automatically refresh if the app is started or brought back from device standby

In my opinion, (1) is the correct expected behavior. I also think that the message "Connection lost. Reconnecting ..." is actually supposed to re-establish the connection but for whatever reason, sometimes it doesn't and remains stuck on the screen.

Screenshots

Image

eigenphase avatar Aug 16 '25 22:08 eigenphase

As another possibly relevant piece of information, I see the following messages in my home assistant log:

[140634317947904] from 10.227.4.2 (Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iPadOS 17.3.1)): Disconnected: Did not receive auth message within 10 seconds
[140634647599264] from 10.227.4.2 (Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iPadOS 17.3.1)): Disconnected: Did not receive auth message within 10 seconds
[140634623723616] from 10.227.4.2 (Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iPadOS 17.3.1)): Disconnected: Did not receive auth message within 10 seconds
[140634140820640] from 10.227.4.2 (Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iPadOS 17.3.1)): Disconnected: Did not receive auth message within 10 seconds
[140634141801536] from 10.227.4.2 (Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iPadOS 17.3.1)): Disconnected: Did not receive auth message within 10 seconds

Also, sometimes I receive the the warning in "Notifications" in Home Assistant that someone intended to log in with wrong username/password. This is coming from the tablet too and definitely not correct. If feel these are may be related to the same bug.

eigenphase avatar Aug 18 '25 22:08 eigenphase

Web content connection (and reconnection logic) is handled by frontend, trasnferring the issue to frontend repo.

bgoncal avatar Aug 19 '25 10:08 bgoncal

Thank you for transferring @bgoncal , however I believe it must still be related to the iOS client:

I have now tried using HA in Safari in extactly the same setup and for the past three days the issue never occurred!

Would you mind giving it another thought what this might be caused by?

eigenphase avatar Aug 23 '25 17:08 eigenphase

I can confirm what @segdy is saying, this is happening exclusively in the iOS app in my experience. Web browsers both on iOS and android seem to not be experiencing the same behavior. I have not tried the android mobile app.

If it helps debug things, mine never works until I fully quit the iOS app and reopen. I’m not exactly sure which version of the app this started happening, but it was certainly within the last couple months. It does not reliably reconnect on its own, but the “quit and reopen” workaround reconnects nearly 100% of the time. This usually happens after the app has been switched to the background, and then I return to it a minute or two later. Logs don’t show anything but it certainly feels like a background refresh issue.

Since the other issue was mentioned, I don’t have external auth enabled. I do have HA cloud enabled

funkybunch avatar Aug 31 '25 11:08 funkybunch

Is there any progress in this topic? I have the same experience on two iPhones, after inactivity the app isnt useable sometimes. the connection stucks. when you try to enable some button, nothing happens. we are trying to refresh the view and sometimes its working, somestimes not and we have to close and open the app again. its really random and feels really bad. there is no issue on any webbased browser systems. we are running an old android 8 tablet with wallpanel app and its perfectly working. also windows with firefox and chrome are working fine. there is only these connection issues on our iphones.

we are experience the issue from local and external connections.

from the companion app logfiles:

2025-10-04 22:14:50.832 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:53.460 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:54.011 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:54.432 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.803 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.804 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.804 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.804 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.804 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.821 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.821 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.821 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.821 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.821 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:55.822 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:14:57.127 [Error] [main] [WebViewController.swift:1022] webView(_:didFailProvisionalNavigation:withError:) > Failure during content load: Error Domain=NSURLErrorDomain Code=-1001 "Zeitüberschreitung bei der Anforderung." UserInfo={NSErrorFailingURLStringKey=https:/***/lovelace/10, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>, NSErrorFailingURLKey=https://***/lovelace/10, networkTaskMetricsPrivacyStance=NotEligible, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>" ), NSLocalizedDescription=Zeitüberschreitung bei der Anforderung., _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x1340bb500>, networkTaskDescription=LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>, _kCFStreamErrorDomainKey=1, NSUnderlyingError=0x135fc1080 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=60, _kCFStreamErrorDomainKey=1}}, _kCFStreamErrorCodeKey=60} 2025-10-04 22:14:57.128 [Error] [main] [WebViewController.swift:766] showSwiftMessage(error:duration:) > Error Domain=NSURLErrorDomain Code=-1001 "Zeitüberschreitung bei der Anforderung." UserInfo={NSErrorFailingURLStringKey=https://***/lovelace/10, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>, NSErrorFailingURLKey=https://***/lovelace/10, networkTaskMetricsPrivacyStance=NotEligible, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>" ), NSLocalizedDescription=Zeitüberschreitung bei der Anforderung., _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x1340bb500>, networkTaskDescription=LocalDataTask <71DD50B4-B825-4A41-90F7-F98BC210E07D>.<108>, _kCFStreamErrorDomainKey=1, NSUnderlyingError=0x135fc1080 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=60, _kCFStreamErrorDomainKey=1}}, _kCFStreamErrorCodeKey=60} 2025-10-04 22:14:59.872 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:15:00.836 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 8) 2025-10-04 22:15:02.013 [Verbose] [main] [XCGLogger+Export.swift:49] archiveURL() > Logs directory is: file:///private/var/mobile/Containers/Shared/AppGroup/3872FAEF-F667-48AF-B8D5-5B59D219DF13/logs/ 2025-10-04 22:15:02.014 [Debug] [main] [XCGLogger+Export.swift:62] archiveURL() > Exporting logs as filename 2025-10-04_22.15.02+0200.logs.zip 2025-10-04 22:15:02.024 [Verbose] [main] [Realm+Initialization.swift:95] getRealm(objectTypes:) > Current schema version 28 2025-10-04 22:15:02.024 [Verbose] [main] [Realm+Initialization.swift:100] getRealm(objectTypes:) > Schema version defined: 28

2025-10-04 01:30:10.869 [Info] [webhookmanager-data] [WebhookManager.swift:432] send(on:server:identifier:request:waitForResponse:) > starting request: taskKey(session: webhook-io.robbie.HomeAssistant, task: 11), server(0611c0a25fc647b185ada22ee71d8760), type(WebhookResponseUpdateSensors), request(WebhookRequest(type: "update_sensor_states", data: [["icon": "mdi:battery-60", "unique_id": "battery_level", "state": 60, "attributes": [:], "type": "sensor"], ["unique_id": "battery_state", "icon": "mdi:battery-60", "type": "sensor", "state": "Not Charging", "attributes": ["Low Power Mode": false]], ["icon": "mdi:database", "unique_id": "storage", "attributes": ["Total": "127,85 GB", "Available (Opportunistic)": "58,52 GB", "Available (Important)": "64,77 GB", "Available": "56,81 GB"], "state": "45.77", "type": "sensor"], ["unique_id": "connectivity_ssid", "icon": "mdi:wifi-off", "state": "Not Connected", "type": "sensor"], ["unique_id": "connectivity_bssid", "icon": "mdi:wifi-off", "type": "sensor", "state": "Not Connected"], ["type": "sensor", "unique_id": "connectivity_connection_type", "state": "Wi-Fi", "icon": "mdi:wifi", "attributes": [:]], ["icon": "mdi:sim", "unique_id": "connectivity_sim_2", "state": "--", "type": "sensor", "attributes": ["Carrier Name": "--", "Mobile Country Code": "65535", "Mobile Network Code": "65535", "ISO Country Code": "--", "Allows VoIP": true, "Carrier ID": "0000000100000002"]], ["unique_id": "connectivity_sim_1", "state": "--", "icon": "mdi:sim", "attributes": ["ISO Country Code": "--", "Allows VoIP": true, "Mobile Network Code": "65535", "Carrier ID": "0000000100000001", "Current Radio Technology": "5G Non-Standalone", "Carrier Name": "--", "Mobile Country Code": "65535"], "type": "sensor"], ["unique_id": "focus", "icon": "mdi:moon-waning-crescent", "state": false, "type": "binary_sensor"], ["icon": "mdi:cellphone-wireless", "state": "Launch", "type": "sensor", "unique_id": "last_update_trigger"], ["state": "2025.9.3", "unique_id": "app-version", "type": "sensor"], ["icon": "mdi:map", "type": "sensor", "unique_id": "location-permission", "state": "Denied"], ["type": "sensor", "icon": "mdi:volume-high", "unique_id": "iphone-audio-output", "state": "Built-in Speaker"]], localMetadata: nil)) 2025-10-04 01:30:10.873 [Info] [com.apple.root.user-initiated-qos] [RealmScene.swift:71] willDelete(objects:server:realm:) > deleting actions [] 2025-10-04 01:30:10.875 [Info] [com.apple.root.user-initiated-qos] [RealmScene.swift:71] willDelete(objects:server:realm:) > deleting actions [] 2025-10-04 01:30:10.927 [Verbose] [com.apple.root.user-initiated-qos] [Realm+Initialization.swift:95] getRealm(objectTypes:) > Current schema version 28 2025-10-04 01:30:10.927 [Verbose] [com.apple.root.user-initiated-qos] [Realm+Initialization.swift:100] getRealm(objectTypes:) > Schema version defined: 28 2025-10-04 01:30:10.928 [Verbose] [main] [AppDatabaseUpdater.swift:40] update() > Updating database, servers count 1 2025-10-04 01:30:10.928 [Verbose] [main] [PanelsUpdater.swift:37] update() > Updating panels, servers count 1 2025-10-04 01:30:10.928 [Error] [main] [WebViewSceneDelegate.swift:166] cleanWidgetsCache() > Failed to remove widgets cache file: Error Domain=NSCocoaErrorDomain Code=4 "„widgets“ konnte nicht entfernt werden." UserInfo={NSUserStringVariant=( Remove ), NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/3872FAEF-F667-48AF-B8D5-5B59D219DF13/caches/widgets, NSURL=file:///private/var/mobile/Containers/Shared/AppGroup/3872FAEF-F667-48AF-B8D5-5B59D219DF13/caches/widgets, NSUnderlyingError=0x149e78d20 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} 2025-10-04 01:30:10.928 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Sending: {"id":118,"type":"config\/entity_registry\/list_for_display"} 2025-10-04 01:30:10.928 [Info] [hakit-work-queue] [Environment.swift:75] init() > WebSocket: Sending: {"id":119,"type":"get_panels"} 2025-10-04 01:30:10.931 [Info] [com.apple.root.user-initiated-qos] [RealmScene.swift:71] willDelete(objects:server:realm:) > deleting actions [] 2025-10-04 01:30:10.942 [Verbose] [main] [Realm+Initialization.swift:95] getRealm(objectTypes:) > Current schema version 28 2025-10-04 01:30:10.942 [Verbose] [main] [Realm+Initialization.swift:100] getRealm(objectTypes:) > Schema version defined: 28 2025-10-04 01:30:10.945 [Error] [main] [CLLocationManager+OneShotLocation.swift:275] locationManager(_:didFailWithError:) > Received CLError: related decl 'e' for CLError(_nsError: Error Domain=kCLErrorDomain Code=1 "(null)")

pLeXwithFleX avatar Oct 04 '25 20:10 pLeXwithFleX

Sadly not :-(

@bgoncal can I re-emphasize that this is NOT a front end issue but indeed iOS app specific? because with Safari everything works without any issues in the same machine & config.

Sadly using Safari makes my wall tablet experience not great because it doesn’t use full screen

eigenphase avatar Oct 04 '25 21:10 eigenphase

I agree. It does not look like an frontend issue. But this should effect a lot of people, is no one else complaining about that?

pLeXwithFleX avatar Oct 05 '25 11:10 pLeXwithFleX

Transferred back to iOS repo

bgoncal avatar Oct 05 '25 16:10 bgoncal

I am experiencing this issue with increasing frequency on my iphone (ios 18.7.1). It's happening roughly once / day at various times. The only resolution that i've found is rebooting my HA host (restarting HA on the host, restarting the companion app, and even restarting my phone doesn't resolve the issue). I can access the HA UI from browsers on my laptop and ios devices, just not the companion app. I lose access to the HA UI from the companion app on my phone. I haven't seen anything that I can determine to be relevant to the issue in the HA logs.

edit: I found the event log in the companion app after it reported failure to connect. Immediately after logging "Application Starting" it reports (at 9:35PM) a Location Update error of "Didn't update: location update from the past":

{
"error": "locationUpdateTooOld",
"start_ssid": "none",
"event": "ZoneManagerEvent(locationChange([<[a lat / long pair]> +/- 1414.00m (speed -1.00 mps / courses -1.00) @ 10/5/25 9:21:24 PM Central Daylight Time]))"
}

I don't know what is providing the location information for the companion app, but it seems that something has changed and now the companion app isn't receiving location information as regularly or frequently as it has in the past.

edit # 2: as follow-up to the observation about location update error, I closed the companion app on my ios device where the log was observed, did not restart HA server, physically moved a fair distance, and then was able to successfully reopen the companion app on my ios device.

jahopki avatar Oct 06 '25 02:10 jahopki

I dunno if you experience the same issue like me and @eigenphase. I have disabled the location service, cause of high battery usage and we dont need the feature.

pLeXwithFleX avatar Oct 12 '25 18:10 pLeXwithFleX

I have the same problem and really have nothing to add. The app loses its connection after a period of inactivity and does not reconnect on its own. Swiping down refreshes the connection immediately, and everything works again for a while. This is extremely frustrating. I have been using the iCab Mobile browser for a few weeks now, and everything works as expected there. It must be an issue with the app.

mifricke avatar Oct 15 '25 14:10 mifricke

Same exact issue here with the iOS Companion App (latest version, running on iPad OS 26). No problems when running HA in Safari. As a workaround for my wall-mounted iPad, I am currently using the free SafeKiosk browser app to hide the status bar.

afmklk avatar Oct 19 '25 12:10 afmklk

I am currently using the free SafeKiosk browser app to hide the status bar.

Would you mind providing a working link? I am still looking for a temporary fix. Your link doesn't work and I did not find this app ...

eigenphase avatar Oct 20 '25 22:10 eigenphase

Would you mind providing a working link? I am still looking for a temporary fix. Your link doesn't work and I did not find this app ...

Link fixed.

afmklk avatar Oct 21 '25 06:10 afmklk

Would you mind providing a working link? I am still looking for a temporary fix. Your link doesn't work and I did not find this app ...

Link fixed.

Thanks! Oh, “not available in your country or region”. That’s the reason I didn’t find it… which country are you in?

eigenphase avatar Oct 22 '25 17:10 eigenphase

is anyone working on this issue?

pLeXwithFleX avatar Dec 15 '25 19:12 pLeXwithFleX