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

Cannot connect to a deleted server when using the Nabu Casa external URL. #3304

Open
DougEdey opened this issue Dec 30, 2024 · 2 comments
Open

Comments

@DougEdey
Copy link

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://<SNIP>.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
@DougEdey
Copy link
Author

I wonder if the issue is that because I have deleted the server once, is there a situation where the app has the server in it multiple times? and the Deleted copy overrides the active copies?

I've tried a full app reset and it doesn't resolve the issue. It also wouldn't explain why I can delete the server when it's connected via a custom URL instead of ui.nabu.casa

@cogneato cogneato assigned cogneato and unassigned cogneato Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@DougEdey @cogneato and others