home-assistant / home-assistant/iOS
Cannot connect to a deleted server when using the Nabu Casa external URL.
- Dominant language
- Swift
- Stars
- 2.4k
- Forks
- 520
- Avg merge
- 7h 27m
- Merged PRs (30d)
- 264
Description
**iOS device model, version and app version**
Model Name: iPhone 15 Pro Max
Software Version: iOS 18.2 (22C152)
App version: 2014.12.2 (2024.1058)
**Home Assistant Core Version**
2024.12.5
**Describe the bug**
When trying to sign in to a Home Assistant instance using the Nabu Casa URL, (`https://*.ui.nabu.casa`) the sign in shows up and works but the next page in the app hangs at connecting.
I do _not_ get this issue with the same server using a NGINX Reverse Proxy
The `ui.nabu.casa` URL works fine in Safari, Chrome, and other browsers on desktop mac and iOS
**To Reproduce**
* Connect to a Home Assistant server with a Nabi.casa URL
* Sign in
* The next screen waits at `Connecting...` with a loading spinner before eventually returning a connection error
**Expected behavior**
The iOS app should connect to a home assistant instance using `ui.nabu.casa`
**Screenshots**
**Additional context**
I have more logs, but I'm not sure if it's safe to broadcast the `ui.nabu.casa` URI in a GitHub issue
The token manager expiration feels odd to me, it's not a "regular" number I'd expect to see.
I'm not sure if this is because it's a deleted server that is causing the issue, I added that to the issue description to be specific about my situation
```
2024-12-29 16:03:00.213 [Info] [main] [Environment.swift:73] init() > WebSocket: connecting using HAConnectionInfo(url: https://.ui.nabu.casa, userAgent: Optional("Home Assistant/2024.12.2 (io.robbie.HomeAssistant; build:2024.1058; iOS 18.2.0)"), engine: nil, evaluateCertificate: Optional((Function)))
2024-12-29 16:03:00.303 [Info] [main] [Environment.swift:73] init() > WebSocket: Viability changed: true
2024-12-29 16:03:00.389 [Info] [main] [Environment.swift:73] init() > WebSocket: connected with headers: ["Sec-WebSocket-Extensions": "permessage-deflate", "Sec-WebSocket-Accept": "G0M9JAApOnIWB7lk1ocrBs+suUs=", "Upgrade": "websocket", "Date": "Sun, 29 Dec 2024 21:03:00 GMT", "Connection": "upgrade", "Server": "Python/3.13 aiohttp/3.11.11"]
2024-12-29 16:03:00.389 [Info] [main] [Environment.swift:73] init() > WebSocket: phase transition to auth
2024-12-29 16:03:00.390 [Error] [main] [TokenManager.swift:122] currentToken > Token -1011415007428477089 is expired by 4091548 seconds
2024-12-29 16:03:00.391 [Info] [hakit-work-queue] [Environment.swift:73] init() > WebSocket: Received: auth: required
2024-12-29 16:03:00.394 [Verbose] [main] [ServerManager.swift:319] serverInfoSetter(cache:keychain:identifier:encoder:notify:) > ignoring update to deleted server 37C5EE44-438F-4D4E-B958-302A9A7D9727
2024-12-29 16:03:00.394 [Info] [main] [TokenManager.swift:176] refreshToken() > starting refreshToken cache
2024-12-29 16:03:00.443 [Info] [refresh-promise-cache-mutex] [TokenManager.swift:147] refreshToken() > reset cached refreshToken promise
2024-12-29 16:03:00.444 [Error] [main] [TokenManager.swift:152] refreshToken() > refresh token got error: responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.customValidationFailed(error: Shared.AuthenticationAPI.AuthenticationError.serverError(statusCode: 400, errorCode: Optional("invalid_grant"), error: nil)))
2024-12-29 16:03:00.444 [Verbose] [main] [ClientEventStore.swift:7] ClientEventStore > Adding client event: ClientEvent(id: "6CAFAD1D-BB9E-470F-864A-CB630C09FE3E", text: "Refresh token is invalid, notifying user", type: Shared.ClientEvent.EventType.networkRequest, jsonPayload: ["error": Shared.AnyCodable(value: "serverError(statusCode: 400, errorCode: Optional(\"invalid_grant\"), error: nil)")], date: 2024-12-29 21:03:00 +0000)
2024-12-29 16:03:00.462 [Error] [main] [Environment.swift:74] init() > WebSocket: delegate failed to provide access token responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.customValidationFailed(error: Shared.AuthenticationAPI.AuthenticationError.serverError(statusCode: 400, errorCode: Optional("invalid_grant"), error: nil))), bailing
2024-12-29 16:03:00.462 [Info] [main] [Environment.swift:73] init() > WebSocket: disconnecting; permanently: false, error: Optional(Alamofire.AFError.responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.customValidationFailed(error: Shared.AuthenticationAPI.AuthenticationError.serverError(statusCode: 400, errorCode: Optional("invalid_grant"), error: nil))))
2024-12-29 16:03:00.462 [Info] [main] [Environment.swift:73] init() > WebSocket: phase transition to disconnected(error: nil, forReset: true)
2024-12-29 16:03:04.564 [Error] [main] [HAAPI.swift:93] init(server:urlConfig:) > couldn't create connection info: emptyHostname
```
Contributor guide
Assessment
This issue has not been assessed yet.