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
500 stars 53 forks source link

Custom `HTTP 530` status code by Cloudflare not recognized by Deck Android as offline server #1663

Open Goldmaster opened 3 months ago

Goldmaster commented 3 months ago

This issue respects the following points:

Describe the bug

When the phone or server is offline, I get a stack trace popup which i then have to close or copy.

Expected behavior

When deck server is offline, either because the nextcloud server is down or phone is offline. I should be able to edit and add cards without issue. Then, when the server is back online, the changes made are reciprocated across to the server, rather than getting some error message.

Deck Android version

1.24.1

Deck server version

1.13.1

Nextcloud Android version

3.29.2

Nextcloud version

29.0.4

Device

samsung s10

Android Version

11

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: 30290290 (PROD)

---

OS Version: 4.14.113-23326020(G973FXXUEGULB)
OS API Level: 31
Device: beyond1
Manufacturer: samsung
Model (and Product): SM-G973F (beyond1lteeea)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP request failed with HTTP status-code: 530
    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:920)
Caused by: java.lang.RuntimeException: HTTP StatusCode wasn't 2xx:
Got [HTTP 530] for Call [GET http://localhost//index.php/apps/deck/api/v1.0/boards/8/stacks/19/cards] with Message:
[error code: 1033
]
    at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.buildCause(RequestHelper.java:87)
    ... 5 more
stefan-niedermann commented 3 months ago

Deck Android is fully offline capable including editing capabilities. It also supports a server being in maintenance mode or not reachable at all.

Maybe you want to explain what a HTTP 530 status codes respinded by your environment is supposed to be? This is a non standard HTTP status code and a s such of course not handeled by Deck Android.

Goldmaster commented 3 months ago

Ah ok, many thanks anyhow.

Seams that I get synchronisation failed at the bottom. With a button for more info, which doesn't have the http 530 code in the stack log.

Seams strange that putting the phone in airplane mode doesn't bring up a large stack trace log.

But if I am on the internet, stop Nextcloud server, then open Nextcloud deck app and go to add a card, that's when I get the full screen oh now what pop up with the stack trace, rather than synchronisation failed at the bottom.

The HTTP 530 status code is likely from Cloudflare.

stefan-niedermann commented 3 months ago

Seams strange that putting the phone in airplane mode doesn't bring up a large stack trace log

It is absolutely reasonable: When the phone knows that it is offline, it does not attempt to synchronize (why should it?) → no error message as the failed synchronization attempt was not expected to work. :heavy_check_mark:

Now your case: Your phone is online, your server is online, your server responds with maintenance mode, a server error, random spaghetti or an invalid HTTP status code - What is your proposal how to react? Hide the error, not signalizing the user the synchronization won't work? No, informing the user that the synchronization failed unexpectedly seems to be correct for me. :x:

Sorry, but sprinkling non-standard cloudflare stuff on your backend seems not to be a good reason to adjust all clients in the world and respect custom fictitious HTTP status codes.

Goldmaster commented 3 months ago

Your phone is online, your server is online

Sorry, do you mean Your phone is online, your server is offline?

Sorry, but sprinkling non-standard cloudflare stuff on your backend seems not to be a good reason to adjust all clients in the world and respect custom fictitious HTTP status codes.

I use Cloudflare tunnels to protest my self-hosted server from bots, DDoS and malware without needing to port forward. Are you saying there is a better option than Cloudflare? What do you use?

stefan-niedermann commented 3 months ago

What I am saying is, that your Cloudflare protection does not behave standards compliant and as such you can by definition not expect any client to work properly.

So, you told that this is happening

When the phone or server is offline

I can't imagine to see a HTTP 530 server response when the phone is offline (how should it get a response? how should it even send a request when offline?), so I can only assume that this happens when your

server is offline

Then the question is what "offline" means. Apache / NginX not reachable? Is your cloud in maintenance mode? What causes your Cloudflare protection to respond with HTTP 530?

Goldmaster commented 3 months ago

Sorry about this,

I believe there may be a miss communication between us.

The issue happens when the phone is online like normal, but if I stop the Nextcloud docker or the server is turned off, that's when I get the full screen stack trace error message.

I hope this clears up the miss understandings.

What causes your Cloudflare protection to respond with HTTP 530?

This would likely be due to the Cloudflare tunnels not connecting due to the server turned off.

Cloudflare protection does not behave standards compliant and as such you can by definition not expect any client to work properly.

What setup do you use that does behave standards compliant?

stefan-niedermann commented 3 months ago

I believe there may be a miss communication between us.

The issue happens when the phone is online like normal, but if I stop the Nextcloud docker or the server is turned off, that's when I get the full screen stack trace error message.

I hope this clears up the miss understandings.

Indeed, thank you for clarifying this. I was confused since you mentioned multiple times your phone being offline (When the phone [...] is offline and When deck [...] is offline, [...] because [...] phone is offline.)

So, I think we now have a common understanding about what's wrong:

Your (online) phone tries to synchronize, while your server is shutdown. Your proposal is to not show a hint when the synchronization failed because your server is offline. When your server is available again, the local changes should get synchronized successfully again to your server (== offline capability).

But I still can't agree to hide this kind of feedback from users. It is not the normal state that a server is offline, it is an exceptional state that should be handled accordingly. Not getting notified about an exceptional state looks wrong from my point of few. If I suppressed this exact notification, I know there will be 2 people tomorrow here complaining that the app silently fails to sync without any hint about what's wrong (a valid complaint from my point of view).

Goldmaster commented 3 months ago

Yeah, fair play. Thank you for your help. So I guess tldr is ditch Cloudflare tunnels when using nextcloud? What set up do you use for accessing Nextcloud with a domain or such?

stefan-niedermann commented 3 months ago

Actually cloudflare is not the issue (though behaving strange).

Tl;DR: Don't shut your nextcloud down to avoid getting notified about unsuccessful synchronization attempts 🙂

juxo commented 2 months ago

Dear Stefan, it seems I have an issue with almost the same bahaviour. This cloudflare info text stopps completely any saving action or sync between phone and my nextcloud instance. The same effect occours with a free nexcloud login from the NC website: xyz.tab.digital So this is not to be solved in the area of my personal NC.

Please send some info soon, meanwhile this is a real sad showstopper to me. There is no better Kanban than this here (assuming it will be working again) Best Axel

stefan-niedermann commented 2 months ago

There is no better Kanban than this here

Thank you for the flowers ❤️

  1. @juxo the same is for you: Your cloudflare protection sends the (imaginary and non-standard) HTTP status code 530.
  2. Why? In case of @Goldmaster it was because his/her Nextcloud instance was offline. When your cloud is offline, the synchronisation can obviously not work. (Please evaluate why your Cloudflare responds with HTTP 530 if not for the same reason).
  3. Notifying the user when the cloud is not reachable for other reasons then an enabled maintenance mode (which is expectedly offline) is mandatory from my point of view. Think about it and tell me you wouldn't expect any kind of notification in case any client can't successful synchronize with any server. A notification is necessary to get aware that there is an issue with your server or network infrastructure and being able to fix it.

So this is not to be solved in the area of my personal NC.

I disagree, depending on your evaluation of 2.

juxo commented 2 months ago

What I did:

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: 4.19.127(1614583247)
OS API Level: 30
Device: WP12
Manufacturer: wheatek
Model (and Product): WP12 (WP12_EEA)

---

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:923)
juxo commented 2 months ago

Funnily sync Works volatily better, still Not perfekt, doublicating lists or cards. So http is out of race