home-assistant / home-assistant/android
Matter commissioning fails: App uses wrong URL (external instead of internal) causing WebSocket connection timeout
- Dominant language
- Kotlin
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 81
Description
**Home Assistant Android app version(s): 2026.1.6-full (20004)**
**Android version(s): 16**
**Device model(s): Samsung Galaxy S23**
**Home Assistant version: 2026.1.3**
**Last working Home Assistant release (if known): n/a**
**Description of problem, include YAML if issue is related to notifications:**
Matter device commissioning fails because the Android Companion app incorrectly selects the external URL for WebSocket connection during Matter commissioning, even though the external URL is unreachable from the phone's network. The app should use the internal URL for Matter commissioning since it's a local network operation.
*Symptoms:*
* App logs show Using external URL decision
* WebSocket connection times out trying to reach external URL (10.0.1.1)
* Commission command never sent to Home Assistant
* Phone is on same local network as HA (10.0.0.x) and can reach internal URL
* WebView correctly uses internal URL (10.0.0.50) but MatterCommissioningService does not
*Expected behavior:*
MatterCommissioningService should use internal URL for local Matter commissioning operations, or correctly determine which URL is reachable.
*Actual behavior:*
App decides to use external URL which is unreachable, causing SocketTimeoutException and failed commissioning.
*Workaround:*
Temporarily setting both internal and external URLs to the same address (internal URL) allows commissioning to succeed.
**Companion App Logs:**
```
02-01 17:27:35.859 24975 32599 D MatterCommissioningService: Received request to commission Matter device
02-01 17:27:35.900 24975 32606 D ServerConnectionStateProviderImplKt: Using external URL
02-01 17:27:35.904 24975 32606 D WebSocketCoreImpl: Creating WebSocket connection
02-01 17:27:45.936 24975 32609 E WebSocketCoreImpl: Websocket: onFailure
02-01 17:27:45.936 24975 32609 E WebSocketCoreImpl: java.net.SocketTimeoutException: failed to connect to /10.0.1.1 (port 1234) from /10.0.0.100 (port 50862) after 10000ms
02-01 17:27:45.936 24975 32609 E WebSocketCoreImpl: at libcore.io.IoBridge.connectErrno(IoBridge.java:235)
02-01 17:27:45.936 24975 32609 E WebSocketCoreImpl: at libcore.io.IoBridge.connect(IoBridge.java:179)
[... stack trace ...]
02-01 17:27:45.938 24975 26811 E WebSocketCoreImpl$awaitAuthAndSetupConnectionHolder$result: Unable to authenticate
02-01 17:27:45.942 24975 24975 W WebSocketCoreImpl: Unable to send message, not connected: WebSocketRequest(message={type=matter/commission_on_network, pin=91503656, ip_addr=fd11:2222:3333:4444:5555:6666:7777:8888}, timeout=2m)
02-01 17:27:45.944 24975 24975 D MatterCommissioningService$onCommissioningRequested: Server commissioning was not successful (null)
02-01 17:27:47.914 24975 24975 D WebViewActivity$onCreate: Matter/Thread step changed to MATTER_IN_PROGRESS
02-01 17:27:47.919 24975 24975 D WebViewPresenterImpl: Matter commissioning returned with non-OK code 0
02-01 17:27:47.923 24975 24975 D WebViewActivity: Waiting for loadedUrl http://10.0.0.50:1234/?external_auth=1
```
Note: Phone is at 10.0.0.100, internal HA URL is 10.0.0.50 (reachable), external HA URL is 10.0.1.1 (unreachable). WebView correctly uses 10.0.0.50 but MatterCommissioningService attempts unreachable 10.0.1.1.
I anonymized this, including addresses, I hope in a consistent way.
**Screenshot or video of problem:**
Matter commissioning fails after "checking connection to thread network" step with generic error message. No screenshots captured as error occurs during commissioning flow.
**Additional information:**
* Device: Android device on WiFi network 10.0.0.x
* HA Server: Internal URL 10.0.0.50:1234 (reachable), External URL 10.0.1.1:1234 (unreachable from phone)
* Matter Device: IKEA device attempting commissioning via Thread
* App behavior: ServerConnectionStateProviderImpl reports "Using external URL" but this URL is not reachable from phone's network
* Root cause: URL selection logic in MatterCommissioningService doesn't correctly evaluate network reachability or doesn't override to use internal URL for local Matter operations
* Workaround confirmed: Setting both URLs to internal address allows commissioning to succeed
This appears to be a bug where MatterCommissioningService uses different URL selection logic than WebView, resulting in connection failures for Matter commissioning even when the app can normally connect to Home Assistant.
Contributor guide
Assessment
This issue has not been assessed yet.