stefan-niedermann / nextcloud-deck

📋 Android client for nextcloud deck app
https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.deck.play
GNU General Public License v3.0
491 stars 53 forks source link

Can't load decks into Android app #1657

Open erahhal opened 1 month ago

erahhal commented 1 month ago

This issue respects the following points:

Describe the bug

  1. Load freshly installed android app
  2. Select already logged in Nextcloud account
  3. 2-3 decks are imported, then an error is thrown

See closed Deck Server issue for more details.

Expected behavior

All decks imported and the app loads

Deck Android version

1.24.1

Deck server version

1.13.1

Nextcloud Android version

3.29.1

Nextcloud version

Nextcloud Hub 8 (29.0.4)

Device

OnePlus 11 5G, Pixel 7 Pro

Android Version

14, LineageOS

App Store

Stacktrace

App Version: 1.24.1
App Version Code: 1024001
Server App Version: 1.13.1
App Flavor: fdroid

Files App Version Code: 30290190 (PROD)

---

OS Version: 5.15.149-gcf9863dbdbf6(ba3a229cd9)
OS API Level: 34
Device: OP594DL1
Manufacturer: OnePlus
Model (and Product): CPH2451 (CPH2449)

---

it.niedermann.nextcloud.deck.exceptions.OfflineException: Connection rejected
    at it.niedermann.nextcloud.deck.remote.api.ServerCommunicationErrorHandler$Handler.handle(ServerCommunicationErrorHandler.java:52)
    at it.niedermann.nextcloud.deck.remote.api.ServerCommunicationErrorHandler.translateError(ServerCommunicationErrorHandler.java:28)
    at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onFailure(RequestHelper.java:95)
    at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:70)
    at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
    at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$n0izO5V3AflskH7z1H8dSLmVKXo(Unknown Source:0)
    at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
    at java.lang.Thread.run(Thread.java:1012)
desperateCoder commented 1 month ago

Hi @erahhal, thanks for your report!

As the message states, the server has rejected the connection. Sounds like an infrastructure-issue to me. Since i saw you're running Nextcloud on Docker: Did you check your configurations on this side? I mean something like maximum-parallel-connections, PHP maximum execution time and so on?

As you stated in the original issue, you don't get logs from nextcloud, but maybe you can check the ones of the NixOS and the PHP running inside it. I'm not too familiar with the whole Docker universe, so there also might be logs or settings regarding the connections? And did you try it more than once (which i'd recommend, since there might be server- and infrastructure-hickups any time)

All I can tell right now: We can't really do anything, if the server refuses to deliver the requested data.

erahhal commented 1 month ago

Yes, I've tried maybe 6-7 times. It always stops after about 3 decks. I can look into the things you mentioned, thanks.

erahhal commented 1 month ago

Is it possible that there is a bug in the Android client or the sync protocol that causes a lot of duplicate or otherwise unnecessary traffic? I'm hosting Nextcloud behind HAProxy, and bumped it to 8 threads and a 100,000 connection limit, and the sync actually went farther, making it to 6 decks before it failed this time. But - it was at 15 MB/s for over a minute before this happened. I only have a few small decks, so no idea what all this traffic is.

Update: The 15 MB/s was a red herring, not caused by Decks. Also, it's making to 5-6 decks today with or without the HAProxy changes, so Just a coincidence. I am noticing that network traffic completely stops for several seconds repeatedly during the import though.

erahhal commented 1 month ago

I spent an hour last night again trying to figure this out. For all gateways in the pipeline, I upped the request limit to 5 minutes. This includes haproxy at the front, and the nginx reverse proxy bundled with the docker image. I also updated the php max exec time, and fastcgi times as well. I confirmed that docker itself does not have any timing limits on network calls itself.

I don't think the timeout issue is coming from gateways. The failure happens in a minute or less after the last request to the backend. Looking at the nextcloud request log, each request takes a while, and the time between each subsequent request is longer. Before it fails, it's making like one request every few seconds, so something is getting clogged up.

As mentioned before, Nextcloud is running perfectly fine, and none of the other dozens of apps have problems, including ones with Android clients, including the Nextcloud client itself, and the Nextcloud recipes app. Deck is doing something different.

erahhal commented 1 month ago

Also, after the error message on Android, requests to the deck API continue to come in when I tail the logs, so something is still happening.

erahhal commented 1 month ago

I think I found something. I cleaned up a lot of the stuff in the log, and found this around the time it was failing:

{"reqId":"O5Y68QpRaFOweRuH1ENs","level":0,"time":"2024-08-18T18:46:37+00:00","remoteAddr":"192.168.2.2","user":"erahhal","app":"no app in context","method":"GET","url":"/index.php/apps/deck/api/v1.1/boards/4/stacks/8/cards/131?","message":"Session token invalidated before logout","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.29.1","version":"29.0.4.1","data":{"user":"erahhal"}}
desperateCoder commented 1 month ago

I think I found something

Well, looks like this might be it! Looks a lot like this one: https://github.com/nextcloud/deck/issues/5938

Might be a similar root cause as the issue above. I'd recommend opening a issue in the server project as above.

erahhal commented 1 month ago

Added this issue, thank you!