Skip to content

Reduce HTTP Timeouts #15210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Reduce HTTP Timeouts #15210

wants to merge 3 commits into from

Conversation

alexknop
Copy link
Collaborator

I have a Nextcloud server with a private server address (192.168.1.2).

When launching the app on my cell phone when I had Wi-Fi off but Cellular data on, I noticed a spinning wheel for about a minute when Nextcloud starts.

I discovered there are many HTTP requests happening on app startup with timeouts of a minute. This can hinder the ability to open offline photos when in this state, possibly due to the many threaded processes.

I think 60 seconds is excessive and was able to manually set timeouts prior to these requests. I have them set to 3 seconds and the app is responding fine now, but I'm open to discussing a better solution to this.

The OwnCloud Client objects have a function to set the default timeouts, but the Nextcloud Client objects do not, and so I had to do so via reflection.

I do not see this issue when on other Wi-Fi networks, possibly because they also use the 192.168.1.0 network and the server availability is determined quicker, but since I use a private IP server, this behavior is noticeable when not on my home Wi-Fi.

Lastly, besides startup, I noticed longer times to load files via the DocumentStorageProvider when my phone is in this connectivity scenario and have a fix in here for that.

@tobiasKaminsky
Copy link
Member

Thanks for that idea.

NextcloudClient can be changed in android-library, thus then using the same timeouts.
I am not an expert on timeouts, thus I hesitate to set it to such a low value, just "because it works for you" (no offense).

However I am open for discussions how to improve/change.
Some ideas

  • what is default on OKHTTP?
  • how are other apps handling it?
  • cache network state, so that only first request needs to time out?

alexknop added 2 commits July 23, 2025 20:37
Signed-off-by: Alex Knop <[email protected]>
Signed-off-by: Alex Knop <[email protected]>
@alexknop
Copy link
Collaborator Author

Thanks for that idea.

NextcloudClient can be changed in android-library, thus then using the same timeouts. I am not an expert on timeouts, thus I hesitate to set it to such a low value, just "because it works for you" (no offense).

However I am open for discussions how to improve/change. Some ideas

* what is default on OKHTTP?

* how are other apps handling it?

* cache network state, so that only first request needs to time out?

Defaults for OkHttpClient appear to be 10 seconds from research, but I am not finding where or how it is changing to higher values in the app. The appcontext is passed into the builder and its possibly layered in the appcontext.

As for other apps, i am really not sure. There is a boolean in OkHttpClient for retryOnConnectionFailure which you could set to false and that would help the retry issue.

I know my case is unique, but I imagine there are other connection scenarios which could create this same pain point, such as having your server accessible over VPN to a private IP and this reacting the same way when not on VPN but connected to the internet. I am not sure if this same scenario applies to a publicly accessibly nextcloud server and the server is down.

Signed-off-by: Alex Knop <[email protected]>
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15210.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

Copy link

Codacy

Lint

TypemasterPR
Warnings4848
Errors1111

SpotBugs

CategoryBaseNew
Bad practice6262
Correctness6166
Dodgy code299303
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3535
Performance4848
Security1818
Total533542

SpotBugs increased!

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants