binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.54k stars 729 forks source link

Android App timeout on self hosted instance #1181

Open y86-dev opened 2 months ago

y86-dev commented 2 months ago

:lady_beetle: Describe the bug Cannot connect to any topic from android app (both fdroid and playstore version) to self hosted ntfy instance. The web interface works without any problems on both PC and my phone.

:computer: Components impacted Android app

:bulb: Screenshots and/or logs

android log ```text This is a log of the ntfy Android app. The log shows up to 1,000 entries. Device info: -- ntfy: 1.16.0 (fdroid) OS: 4.19.318-perf Android: 14 (SDK 34) Model: [REDACTED] Product: [REDACTED] -- Settings: { "autoDeleteSeconds": 2592000, "autoDownloadMaxSize": 102400, "broadcastEnabled": true, "connectionProtocol": "jsonhttp", "darkMode": -1, "defaultBaseUrl": "https://ntfy.[REDACTED]", "lastSharedTopics": [], "minPriority": 1, "mutedUntil": 0, "recordLogs": true } Logs -- 1726315687939 2024-09-14 14:08:07.939 D NtfyLog Log was truncated 1726315689008 2024-09-14 14:08:09.008 D NtfySubscriberMgr Enqueuing work to refresh subscriber service 1726315689017 2024-09-14 14:08:09.017 D NtfyMainActivity Battery: ignoring optimizations = false (we want this to be true); instant subscriptions = false; remind time reached = true; banner = false 1726315694395 2024-09-14 14:08:14.395 D NtfyApiService Checking read access for user [REDACTED] against https://ntfy.[REDACTED]/[REDACTED] 1726315709404 2024-09-14 14:08:29.404 W NtfyAddFragment Connection to topic failed: timeout Exception: java.io.InterruptedIOException: timeout at okhttp3.internal.connection.RealCall.timeoutExit(RealCall.kt:398) at okhttp3.internal.connection.RealCall.callDone(RealCall.kt:360) at okhttp3.internal.connection.RealCall.noMoreExchanges$okhttp(RealCall.kt:325) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:209) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at io.heckel.ntfy.msg.ApiService.checkAuth(ApiService.kt:156) at io.heckel.ntfy.ui.AddFragment$checkReadAndMaybeShowLogin$1.invokeSuspend(AddFragment.kt:209) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Caused by: java.io.IOException: Canceled at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:72) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ... 11 more 1726315710740 2024-09-14 14:08:30.740 D NtfyMainActivity Checking global and subscription-specific 'muted until' timestamp 1726315712440 2024-09-14 14:08:32.440 D NtfySettingsActivity Create io.heckel.ntfy.ui.SettingsActivity@d951924 ```

There is nothing logged by the server when I try to connect using the android app, even under the trace log level.

server.yml ```yml attachment-cache-dir: /var/lib/ntfy-sh/attachments auth-default-access: deny-all auth-file: /var/lib/ntfy-sh/user.db base-url: http://ntfy.[REDACTED] behin-proxy: true cache-duration: 24h cache-file: /var/lib/ntfy-sh/cache-file.db listen-http: :2586 log-level: trace ntfy-admin-name: [REDACTED] ```
nginx config for ntfy ```text server { listen 0.0.0.0:80 ; listen [::0]:80 ; server_name ntfy.[REDACTED] ; location / { return 301 https://$host$request_uri; } } server { listen 0.0.0.0:443 ssl ; listen [::0]:443 ssl ; server_name ntfy.[REDACTED] ; http2 on; ssl_certificate [REDACTED]; ssl_certificate_key [REDACTED]; ssl_trusted_certificate [REDACTED]; location / { proxy_pass http://127.0.0.1:2586; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; client_max_body_size 0; proxy_buffering off; proxy_request_buffering off; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; } } ```

:crystal_ball: Additional context

Seems to be the same issue as reported in #1116, but rebooting the phone and switching the communication method did not fix my issue.

gerrix1701 commented 2 months ago

Same issue here after upgrading server from Ubuntu 22.04 to 24.04. Going back to 22.04 resolves the issue. Maybe related to nginx? I used same nginx config (the one suggested here: https://docs.ntfy.sh/config/#__tabbed_11_2) with both versions of nginx (1.18.0 and 1.24.0).

y86-dev commented 2 months ago

I am on nixos 24.05 with nginx version 1.26.2

y86-dev commented 2 months ago

I noticed that my ipv6 configuration was wrong and my server was reachable only through ipv4 (but it still had dns records for ipv6). I fixed that now and it works. @gerrix1701 maybe that is also your issue?

gerrix1701 commented 2 months ago

I checked my configuration and it did not change when updating to Ubuntu 24.04: