home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.06k stars 584 forks source link

Android Application is loosing connection #4365

Closed AbDhops closed 1 week ago

AbDhops commented 1 week ago

Home Assistant Android app version(s): 2021.4.1-full

Android version(s): 9 and 14 Device model(s): Samsung S21 Samsung S8 Samsung A14

Home Assistant version: 2024.4.1

Home Assistant Setup : Docker on Synology NAS

Last working Home Assistant release (if known): Not known

Description of problem, include YAML if issue is related to notifications:

Companion App Logs:

04-25 17:40:41.917  6430  6430 I WM-SystemFgDispatcher: Started foreground service Intent { act=ACTION_START_FOREGROUND cmp=io.homeassistant.companion.android/androidx.work.impl.foreground.SystemForegroundService (has extras) }
04-25 17:40:42.005  6430  6501 E WebSocketRepository: Unable to connect
04-25 17:40:42.005  6430  6501 E WebSocketRepository: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:229)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at java.lang.Thread.run(Thread.java:764)
04-25 17:40:42.005  6430  6501 E WebSocketRepository: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:646)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:495)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:418)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:339)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:208)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain(ConscryptFileDescriptorSocket.java:404)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:375)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:224)
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   ... 20 more
04-25 17:40:42.005  6430  6501 E WebSocketRepository: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.005  6430  6501 E WebSocketRepository:   ... 31 more
04-25 17:40:42.006  6430  6501 W WebSocketRepository: Unable to send message, not connected: WebSocketRequest(message={type=mobile_app/push_notification_channel, webhook_id=798f8aea8e48553b5608a9699c7e4e2fb42c6712d30c35c4aa3e2c28ebb81e6b, support_confirm=true}, timeout=30000, eventFlow=kotlinx.coroutines.flow.ReadonlySharedFlow@3be8aa6, eventTimeout=0, onEvent=capacity=64,data=[], onResponse=null)
04-25 17:40:42.006  6430  6501 E WebSocketRepository: Unable to subscribe to mobile_app/push_notification_channel with data {webhook_id=798f8aea8e48553b5608a9699c7e4e2fb42c6712d30c35c4aa3e2c28ebb81e6b, support_confirm=true}
04-25 17:40:42.012  6430  5626 E WebSocketRepository: Websocket: onFailure
04-25 17:40:42.012  6430  5626 E WebSocketRepository: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:229)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at java.lang.Thread.run(Thread.java:764)
04-25 17:40:42.012  6430  5626 E WebSocketRepository: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:646)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:495)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:418)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:339)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:208)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain(ConscryptFileDescriptorSocket.java:404)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:375)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:224)
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   ... 20 more
04-25 17:40:42.012  6430  5626 E WebSocketRepository: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
04-25 17:40:42.012  6430  5626 E WebSocketRepository:   ... 31 more

Screenshot or video of problem:

Additional information:

dshokouhi commented 1 week ago

04-25 17:40:42.005 6430 6501 E WebSocketRepository: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

This is not an issue teh app can fix, you will need to either import the CA to the device or regenerate the certificate. The app requires a valid certificate and no handshake errors. The devices CA store is also not the same as the browser so you may not see the issue there.

AbDhops commented 1 week ago

The app requires a valid certificate and no handshake errors.

certificate is valid from Lets encrypt. When I open the HA it does not give me any error in browser. In mobile, when I open, it works for some time, and then shows the issue again.

dshokouhi commented 1 week ago

When I open the HA it does not give me any error in browser.

As I mentioned in my comment that can indeed be the case as apps use a different CA store than the browser.

In mobile, when I open, it works for some time, and then shows the issue again.

this points to a networking issue, again not something the app can fix. In terms of SSL errors the app should never receive any, and if we do we cannot fix it.