After updating, iPhone app will never use internal URL

Seeing a very strange issue. This was working fine before.
First, I have Location Permission to “Always” and Background Refresh “Enabled”
I have motion permission Disabled because I don’t have a need for that.

The app will connect fine and do initial setup using my internal URL (when on WiFi) or external URL (when on cellular):
https://home.mydomain.com:8123 (internal URL)
https://home.mydomain.com (external URL)

When I set it up this way it identifies the URL entered as the External URL which is probably expected.
The problem is, after entering an Internal URL and specifying the SSID (I have to enter it manually), it never recognizes it is using that SSID and keeps using “External URL”.

It doesn’t appear to be a config issue because the app works fine when the External URL is correct for the network that I am on. I just can’t get it to recognize it is on my WiFi and to use the “Internal URL”.

Any ideas?

1 Like

I think there’s 2 issues here:

  1. The SSID isn’t being picked up. Can you double check the permission from the system Settings app for Location? If you recently installed/reinstalled, it will tell the app it’s set to Always but will actually silently be While In Use until it prompts you in the background later.

It’s worth noting that if the SSID is already in the list, it won’t auto-fill; just in case you were looking for that as validation.

  1. The app doesn’t consider port changes alone to be enough to reload the WebView, but it probably should; this is a bug. This means that if you are jumping between internal and external it won’t try and reconnect using the different port. I’ve fixed this for the next release.

Thanks for your reply. This is what I have just tried, it does not appear to be pulling the SSID even when set to “Always”.

  • I verified in settings > privacy > location services that Home Assistant was set to “Always”

  • In Home Assistant app, went to “App Configuration” and selected “Reset” to allow me to reconnect from the beginning

  • On app startup I connected via my internal URL (https://home.mydomain.com:8123)

  • In App Configuration > Connection, this now shows as my External URL

  • I tap on “Internal URL” to configure one, and no SSID’s appear (should my SSID preload here)? I tap on “Add new SSID” and type in my SSID (It’s only three letters)

  • I save the config, and when back on the main overview page, I close and relaunch the app. It always says “Connected via External URL” even though I am on my WiFi with the correct SSID.

Yes this would be helpful in my case. I have an internal DNS, so internally the FQDN resolves to the local address, but when outside the network it resolves to the external address.

1 Like

I’m not sure what is going on; I haven’t seen this happen before, and I believe the location permission is the only thing gating access to that particular feature. A few thoughts:

  1. If you’re on iOS 14, do you have “Precise” location permission enabled? It looks like this is a requirement to get Wi-Fi information in the new APIs for this (which Apple added for iOS 14) so I’m guessing it’s retroactive as well.
  2. Do you have any MDM profiles installed which may be limiting permissions?
  3. Do you have any Restrictions set up for the device? I think this was merged into Screen Time.
  4. Do you have any other Wi-Fi networks you could join as a test? Maybe a Hot Spot on another device?
  5. Does restarting the device fix the issue?

I had a similar issue, but the SSID was picked up fine.
It turned out to be an issue with my internal DNS server ; it resolved the external IP, and not my local IP

You can use a tool f.e. Net Analyzer (ping) on your IPhone to see what address is resolved

Why do you use your external domain with port 8123 as internal URL, you should use http://ip-of-ha:8123 or http://local-hostname-of-ha:8123. Otherwise it’s an issue with your router settings that it doesn’t translate your external domain when you try to access it locally.

This resolved the SSID issue… I didn’t have “Precise” enabled as I thought it would help conserve battery.

But now I may be running into the second issue which could be a bug.

On first time use of the app, I am on LTE (WiFi is off) and I connect to Home Assistant using the external URL:
https://home.mydomain.com

App connects and everything looks fine.

I turn on WiFi and relaunch Home Assistant app. I add Internal URL (https://home.mydomain.com:8123) and SSID is now populated and app connects ok. Connection information shows it is now using internal URL! Everything looks fine.

Now I turn off WiFi and use LTE. App now shows it is using External URL, but the screen does not load. I just see a spinner at the top which eventually gives a timeout error.

After exporting the logs and looking at the timeout error, it looks like it is using the INTERNAL URL even though app is reporting the EXTERNAL URL is in use. The timeout in the error below is for the internal URL. I am on LTE and the app connection info shows the External URL is in use. (I changed the FQDN in the error message to conceal actual URL)

2020-10-06 14:25:46.238 [Error] [main] [WebViewController.swift:367] webView(_:didFailProvisionalNavigation:withError:) > Failure during content load: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLKey=https://home.mydomain.com:8123/lovelace/default_view, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <80DDEBC8-4270-43DF-AC76-B9F758AE8089>.<2>, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out., _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x281d90500>, networkTaskDescription=LocalDataTask <80DDEBC8-4270-43DF-AC76-B9F758AE8089>.<2>, _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://home.mydomain.com:8123/lovelace/default_view, NSUnderlyingError=0x28130c630 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}}

Yes that looks like the port bug I referenced above. Should be fixed in the next TestFlight beta and App Store release.

Precise location being disabled will more or less prevent any location updates. It kills region monitoring and other features and provides accuracies that exceed our minimum accuracy threshold. I’ve augmented the “deal with precise location” ticket to include this new SSID information too.

Because I have my home assistant server in a separate vlan dedicated to untrusted IoT stuff, and I don’t want http auth enabled on it.
But even if I wanted to, I don’t believe it’s an option if you specify a cert and key in the http section of configuration.yaml:

http:
ssl_certificate: /ssl/certchain.pem
ssl_key: /ssl/certkey.pem

As you can see it expects https when those are specified:

~ % curl http://192.168.10.10:8123
curl: (52) Empty reply from server

~ % curl http://home.mydomain.com:8123
curl: (52) Empty reply from server

~ % curl -k https://home.mydomain.com:8123

body{font-family:Roboto,sans-serif;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-weight:400;margin:0;padding:0;height:100%}Home Assistant

[snipped]

1 Like

That will work on un-encrypted (http), but it will not work on https, as the certificate won’t match the name (which isn’t a name but an IP-address):
image

In case anyone else runs into this, I had precisely the problem described in this post. TLDR; Go to your WIFI Connection’s setting in iOS15 and turn off “iCloud Private Relay” for your home SSID.

To recap the details: the Home Assistant iOS app worked fine on cellular but not on my home SSID. It seemed to be suddenly not working without any changes (several days after I upgraded to iOS 15 and was working before). The iOS export logs showed this:

2021-11-07 21:23:15.791 [Error] [main] [WebViewController.swift:333] webView(_:didFailProvisionalNavigation:withError:) > Failure during content load: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLKey=https://hass.mydomain.com:8123/lovelace-garage/0, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <45807F48-97AF-4770-A795-EEDE0CF3699C>.<2>, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out., _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x282f85860>, networkTaskDescription=LocalDataTask <45807F48-97AF-4770-A795-EEDE0CF3699C>.<2>, _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://hass.mydomain.com:8123/lovelace-garage/0, NSUnderlyingError=0x28219d7a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}}

The super weird thing was I could open the same URL in this error in safari on the same device and it worked fine. I suppose the issue is that I am running a “split DNS” where my DNS server at home returns a local IP. I guess iCloud Private Relay tries to use that IP but from outside my network and it fails. Unclear to me why Safari works fine though and the Home Assistant iOS app doesn’t.

The reason I didn’t connect the dots here is that Apple Mail prompted to use private relay and I accepted in the moment and never fully appreciated that all traffic started going to private relay (all but safari??).