Notes app can't handle a basic 301 redirect

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): nextcloud-25.0.1-1.fc35.noarch nextcloud-nginx-25.0.1-1.fc35.noarch
Operating system and version (eg, Ubuntu 20.04): Fedora 35
Apache or nginx version (eg, Apache 2.4.25): nginx-1.22.1-1.fc35.x86_64
PHP version (eg, 7.4): php-cli-8.0.26-1.fc35.x86_64 php-fpm-8.0.26-1.fc35.x86_64

The issue you are facing:

Notes app can’t connect to my nextcloud server. I’ve been using the official nextcloud app for years without issue, instant upload is working flawlessly, but today I decided I wanted to try out the official notes app. Sadness ensued.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install the Notes app from the google play store.
  2. Select my existing nextcloud account.
  3. Get frustrated.

Android app barfs with this message:

App Version: 4.0.0
App Version Code: 40000090
App Flavor: play

Files App Version Code: 30250090

---

OS Version: 4.9.227-perf+(2111252325)
OS API Level: 30
Device: OnePlus6
Manufacturer: OnePlus
Model (and Product): ONEPLUS A6003 (OnePlus6)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP-Anfrage ist fehlgeschlagen mit HTTP-Statuscode: 301
	at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:188)
	at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:199)
	at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:129)
	at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda0.subscribe(Unknown Source:6)
	at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
	at io.reactivex.Observable.subscribe(Observable.java:12284)
	at io.reactivex.internal.operators.observable.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31)
	at io.reactivex.Maybe.subscribe(Maybe.java:4290)
	at io.reactivex.Maybe.blockingGet(Maybe.java:2320)
	at io.reactivex.Observable.blockingSingle(Observable.java:5381)
	at it.niedermann.owncloud.notes.persistence.CapabilitiesClient.getCapabilities(CapabilitiesClient.java:32)
	at it.niedermann.owncloud.notes.importaccount.ImportAccountActivity.lambda$onActivityResult$5$it-niedermann-owncloud-notes-importaccount-ImportAccountActivity(ImportAccountActivity.java:96)
	at it.niedermann.owncloud.notes.importaccount.ImportAccountActivity$$ExternalSyntheticLambda2.run(Unknown Source:4)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.IllegalStateException: <html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.22.1</center>
</body>
</html>

	at com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:454)
	at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:127)
	at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:110)
	at com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:158)
	at android.os.Binder.execTransactInternal(Binder.java:1165)
	at android.os.Binder.execTransact(Binder.java:1134)

The output of your Nextcloud log in Admin > Logging:

No server logs
Everything is working fine

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
  ),
  'log_type' => 'syslog',
  'syslog_tag' => 'nextcloud',
  'logfile' => '',
  'loglevel' => 0,
  'debug' => true,
  'datadirectory' => '/srv/storage/nextcloud/',
  'updatechecker' => false,
  'check_for_working_htaccess' => false,
  'asset-pipeline.enabled' => false,
  'assetdirectory' => '/var/lib/nextcloud',
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/usr/share/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/lib/nextcloud/apps',
      'url' => '/apps-appstore',
      'writable' => true,
    ),
  ),
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.malloc.hackerbots.net',
  ),
  'dbtype' => 'pgsql',
  'version' => '25.0.1.1',
  'overwrite.cli.url' => 'http://localhost',
  'installed' => true,
  'instanceid' => 'octhymfssja3',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'malloc.hackerbots.net',
  'mail_smtphost' => 'relay.malloc.hackerbots.net',
  'app_install_overwrite' =>
  array (
    0 => 'files_external_gdrive',
    1 => 'duplicatefinder',
  ),
  'default_phone_region' => 'DE',
  'maintenance' => false,
  'mail_smtpport' => '25',
  'dbname' => 'nextcloud',
  'dbhost' => 'relay:5432',
  'dbuser' => 'XXX',
  'dbpassword' => 'XXX',
  'theme' => '',
  'enable_previews' => true,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\Movie',
    1 => 'OC\\Preview\\PNG',
    2 => 'OC\\Preview\\JPEG',
    3 => 'OC\\Preview\\GIF',
    4 => 'OC\\Preview\\BMP',
    5 => 'OC\\Preview\\XBitmap',
    6 => 'OC\\Preview\\MP3',
    7 => 'OC\\Preview\\MP4',
    8 => 'OC\\Preview\\TXT',
    9 => 'OC\\Preview\\MarkDown',
    10 => 'OC\\Preview\\PDF',
  ),
  'preview_imaginary_url' => 'http://127.0.0.1:9188/',
);

The output of your Apache/nginx/system log in /var/log/____:

10.0.0.146 - tdfischer [27/Jul/2023:10:01:01 +0200] "nextcloud.malloc.hackerbots.net" "GET /nextcloud/ocs/v2.php/cloud/capabilities?format=json HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.25.0" "-"

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

No errors reported in logs.

Hello and welcome to the community support forum :wave:

Please note that this is a known issue of the Nextcloud Single Sign On library which does not only affect the Notes apo but also Deck, News, Tables and any other Android app that uses tthis library.

It therefore can not be fixed in the 3rd party Android apps themselfes, but needs to get fixed in the SSO library.

Kind regards

First reported in 2020…3 years later no fix yet? How many more years do we wait?

After all a 301 does redirect to some place. Couldn’t you just use the URL it redirects to? I mean yes it would be nice if the issue would be fixed, on the other hand if you could help yourself that way you wouldn’t have to wait any longer… :wink:

I can’t see what the 301 goes to, because this is all wrapped up in SSL and issued by the server itself. This is internal nextcloud library magic, I cannot simply “use” the URL the API gives me, because I am not developing the app or library that is using the API. I’m an ancient systems engineer from before the internet had URLs, I was there when that magic was written. This isn’t my first rodeo.

So, you didn’t add any 301 redirects to your webserver config then?

No, I did not add any such redirects. The stacktrace clearly shows that it is attempting to parse the body of the 301 as JSON instead of simply following it. Even if I added 301 redirects, I would expect a sane HTTP client to treat them like normal. A 301 is never an error.

Hmm not sure then. I never had an issue with the Notes app, or any other apps that are using Nextcloud’s SSO on my Android devices. However, I’m using Apache, meaning most of this “magic” is handeled by the .htaccess file that is provided by Nextcloud. So if I had to guess, I’d say there must be something in your Nginx config that causes this…

1 Like

I can promise you that my nginx configuration does not cause my phone to crash when receiving a standard 301 that follows the HTTP RFCs.