Server: [download with android] too many redirects

Created on 8 Jul 2016  Â·  24Comments  Â·  Source: nextcloud/server

when i try to download any file from an Link i got an error. only from mobile devices it won´t work. from Desktop it works fine.

Steps to reproduce

  1. upload an File
  2. share this file
  3. try to download from link with your Android device [https://cloud-surfer.eu/s/6XKvVD5NITHSked]

    Actual behaviour

Downloaded file is corrupt. Download stops with "_Filexyz_ konnte aufgrund von Serverproblemen nicht heruntergeladen werden"

Server configuration

Operating system:

Web server:

Database:

PHP version:

Nextcloud version: (see Nextcloud admin page)

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from:

Signing status (Nextcloud 9.0 and above):


Signing status

No errors have been found.

List of activated apps:


App list

Enabled:
  - activity: 2.2.1
  - admin_audit: 1.0.0
  - bookmarks: 0.7
  - calendar: 1.2.2
  - comments: 0.2
  - contacts: 1.3.1.0
  - dav: 0.1.6
  - documents: 0.12.0
  - fbsync: 1.8.2
  - federatedfilesharing: 0.1.0
  - federation: 0.0.4
  - files: 1.4.4
  - files_external: 0.5.2
  - files_mv: 0.8.2
  - files_pdfviewer: 0.8.1
  - files_sharing: 0.9.1
  - files_texteditor: 2.1
  - files_trashbin: 0.8.0
  - files_versions: 1.2.0
  - files_videoplayer: 0.9.8
  - firstrunwizard: 1.1
  - gallery: 14.5.0
  - libreonline: 0.1
  - mail: 0.5.2
  - music: true
  - news: true
  - notifications: 0.2.3
  - ocdownloader: 1.5
  - password_policy: 1.0.0
  - provisioning_api: 0.4.1
  - systemtags: 0.2
  - tasks: true
  - templateeditor: 0.1
  - theming: 0.1.0
  - updatenotification: 0.1.0
Disabled:
  - encryption
  - external
  - galleryplus
  - piwik
  - richdocuments
  - user_external
  - user_ldap
  - user_saml

The content of config/config.php:


Config report

{
    "system": {
        "updatechecker": true,
        "instanceid": "ocernowp783d",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud-surfer.eu"
        ],
        "datadirectory": "\/mnt\/owncloud\/data",
        "overwrite.cli.url": "https:\/\/cloud-surfer.eu",
        "dbtype": "mysql",
        "version": "9.0.52.0",
        "logtimezone": "Europe\/Berlin",
        "installed": true,
        "maintenance": false,
        "dbname": "owncloud2",
        "dbhost": "127.0.0.1",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "lars",
        "mail_smtpmode": "php",
        "mail_domain": "cloud-surfer.eu",
        "loglevel": 0,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "localhost",
            "port": 6379
        },
        "appstore.experimental.enabled": true,
        "htaccess.RewriteBase": "\/",
        "updater.server.url": "https:\/\/updates.nextcloud.org\/updater_server\/",
        "theme": "",
        "updater.release.channel": "daily"
    }
}

Are you using external storage, if yes which one: local/smb/sftp/...
no
Are you using encryption: yes/no
no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

no

Client configuration

Browser:
Android latest Chrome Browser, Stock Android Browser
Operating system:
Windows 10, Android 6.0.1

Logs

Web server error log


Web server error log

016-07-08 07:18:22  Access  151.252.223.201 200 GET /ocs/v1.php/apps/files_sharing/api/v1/shares?path=%2FPublic%2F&reshares=true&subfiles=true HTTP/1.1     Mozilla/5.0 (Android) nextcloud-android/1.1.0   3.99 K  Apache-SSL-Zugriff
2016-07-08 07:18:23 Access  151.252.219.4   200 GET /ocs/v2.php/apps/notifications/api/v1/notifications?format=json HTTP/1.1        Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 1.04 K  Apache-SSL-Zugriff
2016-07-08 07:18:25 Access  151.252.223.201 200 GET /ocs/v1.php/apps/files_sharing/api/v1/shares?path=%2FPublic%2Fcom.nianticlabs.pokemongo_0.29.0.apk&reshares=false&subfiles=false HTTP/1.1       Mozilla/5.0 (Android) nextcloud-android/1.1.0   3.12 K  Apache-SSL-Zugriff
2016-07-08 07:18:27 Access  151.252.223.201 200 GET /ocs/v1.php/apps/files_sharing/api/v1/shares?path=%2FPublic%2Fcom.nianticlabs.pokemongo_0.29.0.apk&reshares=false&subfiles=false HTTP/1.1       Mozilla/5.0 (Android) nextcloud-android/1.1.0

Nextcloud log (data/nextcloud.log)

But i think nothing to do with this problem (different time)


Nextcloud log

Error   PHP Undefined variable: share at /var/www/vhosts/cloud-surfer.eu/httpdocs/nextcloud/lib/private/share20/manager.php#996 2016-07-08T02:58:51+02:00   --
Error   PHP Undefined index: defaultValue at /var/www/vhosts/cloud-surfer.eu/httpdocs/nextcloud/core/ajax/appconfig.php#47  2016-07-08T01:09:33+02:00   Lars
Error   PHP Undefined index: defaultValue at /var/www/vhosts/cloud-surfer.eu/httpdocs/nextcloud/core/ajax/appconfig.php#47  2016-07-08T00:54:00+02:00   Lars
Error   PHP Undefined index: defaultValue at /var/www/vhosts/cloud-surfer.eu/httpdocs/nextcloud/core/ajax/appconfig.php#47  2016-07-08T00:53:22+02:00   Lars
Error   PHP Undefined variable: share at /var/www/vhosts/cloud-surfer.eu/httpdocs/nextcloud/lib/private/share20/manager.php#996 2016-07-08T00:52:48+02:00   --
Fatal   webdav  Exception: {"Message":"HTTP\/1.1 409 Parent node does not exist","Exception":"Sabre\\DAV\\Exception\\Conflict","Code":0,"Trace":"#0 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php(588): Sabre\\DAV\\Server->createCollection('SofortUpload\/20...', Object(Sabre\\DAV\\MkCol))\n#1 [internal function]: Sabre\\DAV\\CorePlugin->httpMkcol(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#2 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#3 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(459): Sabre\\Event\\EventEmitter->emit('method:MKCOL', Array)\n#4 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(248): Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#5 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/apps\/dav\/appinfo\/v1\/webdav.php(55): Sabre\\DAV\\Server->exec()\n#6 \/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/remote.php(138): require_once('\/var\/www\/vhosts...')\n#7 {main}","File":"\/var\/www\/vhosts\/cloud-surfer.eu\/httpdocs\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php","Line":1107,"User":"Lars"}  2016-07-07T23:51:02+02:00   Lars

Browser log


Browser log

no entry on Desktop

android log


Browser log

Android:

07-08 07:18:50.381 29072 29082 W DownloadManager: Path appears to be invalid: /storage/emulated/0/Download/com.nianticlabs.pokemongo_0.29.0.apk
07-08 07:18:50.480 29072 32392 D DownloadManager: [278] Starting
07-08 07:18:50.492 29072 32392 W ActivityThread: ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
07-08 07:18:50.498  1612  2136 W StreamManager: Dropping non-bitmap icon from notification.
07-08 07:18:50.523  1612  2136 W StreamManager: Dropping non-bitmap icon from notification.
07-08 07:18:50.539 32030 32050 V RenderScript: 0x8fd8b000 Launching thread(s), CPUs 4
07-08 07:18:52.124 29072 32392 W DownloadManager: [278] Stop requested with status TOO_MANY_REDIRECTS: Too many redirects
07-08 07:18:52.125 29072 32392 D DownloadManager: [278] Finished with status TOO_MANY_REDIRECTS
bug

Most helpful comment

i found one error in Chrome with remote debugging.

Resource interpreted as Document but transferred with MIME type application/vnd.android.package-archive: "https://cloud-surfer.eu/s/6XKvVD5NITHSked/download".

What is wrong?

Chrome Bug report

All 24 comments

Why in Android, it's an Server Problem... I don't use the Android app from nextcloud for this.

Ah okay, sorry then I didnt read correctly

I could download this file and open the apk with the Android package manager without problems. The browser I used is "Gello", the new stock browser delivered in Cyanogenmod and based on Chromium.

With Gello it works. Strange

Same Problem here ...
With chrome on mobile the Download brokes with a server error..
On Desktop ist works fine...
i tested gello too and it works... curious

anyone an idea?

No idea...
When gello based on chrome, i can´t imagine where the problem is...
I´ve only got a server error message with no more information...

I just tried here on my CM (android 6) in chrome and gello. Both work for me...

Would any of you be able to log the requests? (Don't know if there are debug tools like that for mobile?)

i use adb shell logcat /mnt/sdcard/log.txt for that.

I think this is a problem of chrome mobile...
Beacause, with the native browser in Android 4.4 on HTC devices and with the AddBlockBrowser the download works too.

I also think that it is an issue specific to Chrome(ium) on Android. In contrast to that Chromium on the (Linux) desktop works fine…

i found one error in Chrome with remote debugging.

Resource interpreted as Document but transferred with MIME type application/vnd.android.package-archive: "https://cloud-surfer.eu/s/6XKvVD5NITHSked/download".

What is wrong?

Chrome Bug report

@Happyfeet01 you can't download only shared files? I can't download everything.

Some new news about this "feature" out there?

@Echse27 Allegedly it is a bug of Google Chrome. But in 52 there is no any changes. As workaround you can use Firefox or just official Nextcloud app.

@Lord-Protector: That does not really help with other people who are not in your cloud...

@ToeiRei workaround is only partly solution of problem. Other people can just use other browser if you explain them about this bug.

@LukasReschke and I debugged this a bit - the first commit where this happens is 2c6a5fc (add same site cookie).

We proxied the connection and the file is downloaded twice (before this was both times a 200, afterwards first a 200 and then a 302). This looks like the first request is done by Chrome and the other one by the Download app on Android. The second request doesn't hold the "same site" cookie and causes a 302.

And yay! This is a feature of Android! Because why use HEAD if you can just download files twice! 🚀

See https://code.google.com/p/android/issues/detail?id=1978

And yay! This is a feature of Android! Because why use HEAD if you can just download files twice! 🚀

And this is also the case for 150 MB files ... it simply downloads them twice 😵

And even more yay! Android is really insane when it is about cookies. So what happens is:

  1. Nextcloud sets cookies with a Same-Site attribute
  2. Chrome Android accepts it and sends it properly
  3. The first download using Chrome works
  4. It is redownloaded with the Download Manager which does just completely drops cookies with the same-site attribute

🙈 🙉 🙊

Please test #1454

This works for me 🙌

Was this page helpful?
0 / 5 - 0 ratings