Hi,
I’m using the companion app on my iPhone as well as on my iPad.
My iPad never leaves my home and I have never had any issues with the companion app on it.
However, on my iPhone, it seems the app regularly forgets its configuration settings.
When I am not connected to my home wifi network (i.e. “on the road”), I can only access my HA instance through a VPN tunnel.
I have installed OpenVPN on my phone and explicitely need to activate the tunnel in order to use the HA companion app.
For this to work, I have configured an internal and an external URL in the app settings.
Now it seems to me that, whenever the HA app cannot successfully connect to HA even once, it discards all its configuration data.
The next time I open the app (even if it’s at home, connected to my home wifi network), I am greeted with the “welcome”-screen and I’m given the option to detect any local HA instances.
All works fine after that - except that I again need to add the external URL every single time.
Would it be possible to have some kind of “retry” button if the HA connection fails?
Or at least to give the user a chance to preserve the existing configuration?
That would really prevent a lot of frustration on my end.
When the app logs itself out, it puts an entry in its event log with the details of why. In App Configuration > Debugging. Tap on the row in Event Log for more details.
Thanks!
I’ve found one message “Refresh token is invalid, showing onboarding” which sounds exactly like what is happening.
Checking the details, I see a 403 error response from the server - this is what happens when I try to access it “from outside” without an active VPN connection.
2022-04-28 15:29:00.940 [Info] [main] [ClientEventStore.swift:8] ClientEventStore > networkRequest: Webhook failed with status code 403 [:]
2022-04-28 15:29:00.943 [Info] [refresh-promise-cache-mutex] [TokenManager.swift:140] refreshToken() > reset cached refreshToken promise
2022-04-28 15:29:00.943 [Error] [main] [WebhookManager.swift:582] urlSession(_:task:didCompleteWithError:) > failed request to 5BB02F9C-7DF1-4024-A052-2BAB3A5B8CF4 for WebhookResponseLocation: unacceptableStatusCode(403)
2022-04-28 15:29:00.945 [Error] [webhookmanager-data] [WebhookManager.swift:284] send(identifier:server:request:) > in-background non-background failed: unacceptableStatusCode(403)
2022-04-28 15:29:00.953 [Error] [main] [TokenManager.swift:145] refreshToken() > refresh token got error: responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.customValidationFailed(error: Shared.AuthenticationAPI.AuthenticationError.serverError(statusCode: 403, errorCode: nil, error: Optional("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don\'t have permission to access this resource.</p>\n</body></html>\n"))))
2022-04-28 15:29:00.954 [Info] [main] [ClientEventStore.swift:8] ClientEventStore > networkRequest: Refresh token is invalid, showing onboarding ["error": serverError(statusCode: 403, errorCode: nil, error: Optional("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don\'t have permission to access this resource.</p>\n</body></html>\n"))]
So at this point, in my view there should be an option to dismiss the onboarding dialog and just keep the existing configuration.
The app largely doesn’t handle this class of issues, where there’s some kind of proxy in the middle which returns application-level errors that aren’t application errors. If the app were to disregard the 403 in this case, it’s likely to get banned from other API calls depending on the HA config, if it were talking to HA.
It’s potentially possible the app could keep track of these previously-invalidated server configs and offer to use them during onboarding, but it won’t solve the overall issue - the app needs to trust the HTTP responses it gets back, so you’ll still get logged out.
It would be perfectly fine for me, if the apps response to this kind of error would be to show some kind of dialog like:
Invalid/Unexpected response received from server.
[Retry] [Launch Configuration]
Is that not possible?
The log out also would not be an issue for me.
I authenticate via Trusted Networks, so logging in again is quickly done.
What’s annoying is that I always need to add the external URL again.
I also remember having to configure the “list” of home wifi networks (one, in my case) so the app uses the “internal URL” when connected to this network.
I couldn’t find that setting anymore, though, so maybe that’s was in an older version.