Server: "Connection to server lost" error when uploading/downloading large files

Created on 3 May 2017  Â·  10Comments  Â·  Source: nextcloud/server

Steps to reproduce

  1. Log in to Nextcloud instance.
  2. Attempt to upload a large (>10MB) file.

Expected behaviour

File should be uploaded and stored in the directory of the user's file share.

Actual behaviour

Uploaded ceases abruptly with a "connection to server lost" error.

This error has also been seen when downloading large files to an Android device, and sporadically when listing files or using the News app.

Server configuration

Operating system: Debian jessie

Web server: nginx 1.13.0 (based on Docker image wonderfall/nginx-php)

Database: MariaDB 10.1.22+maria-1~jessie (based on Docker image mariadb)

PHP version: 7.1.4 (based on Docker image wonderfall/nginx-php)

Nextcloud version: 12.0.0 (but also seen on 11.2 and 11.3)

Redis version: 3.2.8 (based on Docker image redis:alpine)

Updated from an older Nextcloud/ownCloud or fresh install: Upgraded from older version, but verified present on clean install of 11.3.

Where did you install Nextcloud from: Docker container based on wonderfall/nextcloud:12.0

Signing status:


Signing status

No errors have been found.

List of activated apps:


App list

Enabled:
  - calendar: 1.5.2
  - contacts: 1.5.3
  - dav: 1.3.0
  - federatedfilesharing: 1.2.0
  - federation: 1.2.0
  - files: 1.7.2
  - files_markdown: 1.0.1
  - files_opds: 0.8.2
  - files_pdfviewer: 1.1.1
  - files_reader: 1.0.4
  - files_sharing: 1.4.0
  - files_texteditor: 2.4.1
  - files_trashbin: 1.2.0
  - files_versions: 1.5.0
  - files_videoplayer: 1.1.0
  - gallery: 17.0.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.0.0
  - news: 10.2.0
  - nextcloud_announcements: 1.1
  - notifications: 2.0.0
  - provisioning_api: 1.2.0
  - serverinfo: 1.2.0
  - sharebymail: 1.2.0
  - survey_client: 1.0.0
  - tasks: 0.9.5
  - theming: 1.3.0
  - twofactor_backupcodes: 1.1.0
  - updatenotification: 1.2.0
  - workflowengine: 1.2.0
Disabled:
  - activity
  - admin_audit
  - audioplayer
  - comments
  - encryption
  - external
  - files_external
  - firstrunwizard
  - password_policy
  - systemtags
  - user_external
  - user_ldap

Nextcloud configuration:


Config report

{
    "system": {
        "datadirectory": "\/data",
        "apps_paths": [
            {
                "path": "\/nextcloud\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/apps2",
                "url": "\/apps2",
                "writable": true
            }
        ],
        "memcache.local": "\\OC\\Memcache\\APCu",
        "redis": {
            "host": "redis",
            "port": 6379
        },
        "instanceid": "ocadc83b19e7",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "nebula.logomancy.net"
        ],
        "overwrite.cli.url": "https:\/\/nebula.logomancy.net",
        "dbtype": "mysql",
        "version": "12.0.0.16",
        "dbname": "nextcloud",
        "dbhost": "db",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "America\/New_York",
        "installed": true,
        "mail_from_address": "raven",
        "logdateformat": "Y-m-d H:i:s",
        "mail_smtpmode": "smtp",
        "appstoreenabled": true,
        "appstoreurl": "https:\/\/apps.nextcloud.com\/api\/v0",
        "appstore.experimental.enabled": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\Image",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\Epub",
            "OC\\Preview\\PDF"
        ],
        "maintenance": false,
        "loglevel": 2,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "mail_domain": "logomancy.net",
        "mail_smtpauth": 1,
        "mail_smtpauthtype": "PLAIN",
        "mail_smtphost": "surkesh.logomancy.net",
        "mail_smtpport": "587",
        "mail_smtpsecure": "tls",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "theme": ""
    }
}

Are you using external storage, if yes which one: No

Are you using encryption: No

Are you using an external user-backend, if yes which one: No

Client configuration

Browser: Pale Moon 27.2.1 (also seen with Firefox 53.0)

Operating system: Manjaro Linux

Logs

Web server error log


Web server error log

No errors present in error log.

Nextcloud log (data/nextcloud.log)


Nextcloud log

{"reqId":"hx176ARwQ1Bhblp4CL5F","level":4,"time":"2017-05-03 11:48:20","remoteAddr":"172.19.0.1","user":"andrew","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/Documents\/Books\/RPG\/7th%20Sea\/NationsofTheah_Vol1_LowRes_DT_2017_04_14.pdf","message":"Exception: {\"Message\":\"HTTP\\\/1.1 400 expected filesize 17713100 got 3973120\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\BadRequest\",\"Code\":0,\"Trace\":\"#0 \\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(149): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->put(Resource id #11)\\n#1 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1095): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->createFile('NationsofTheah_...', Resource id #11)\\n#2 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(525): Sabre\\\\DAV\\\\Server->createFile('Documents\\\/Books...', Resource id #11, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#6 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/nextcloud\\\/remote.php(162): require_once('\\\/nextcloud\\\/apps...')\\n#9 {main}\",\"File\":\"\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":151,\"User\":\"andrew\"}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:45.9) Gecko\/20100101 Goanna\/3.2 Firefox\/45.9 PaleMoon\/27.2.1","version":"12.0.0.16"}
{"reqId":"GjyDVppUULr0Xuq3eUIb","level":4,"time":"2017-05-03 11:50:49","remoteAddr":"172.19.0.1","user":"andrew","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/Documents\/Books\/RPG\/7th%20Sea\/NationsofTheah_Vol1_LowRes_DT_2017_04_14.pdf","message":"Exception: {\"Message\":\"HTTP\\\/1.1 400 expected filesize 17713100 got 3104768\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\BadRequest\",\"Code\":0,\"Trace\":\"#0 \\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(149): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->put(Resource id #11)\\n#1 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1095): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->createFile('NationsofTheah_...', Resource id #11)\\n#2 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(525): Sabre\\\\DAV\\\\Server->createFile('Documents\\\/Books...', Resource id #11, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#6 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/nextcloud\\\/remote.php(162): require_once('\\\/nextcloud\\\/apps...')\\n#9 {main}\",\"File\":\"\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":151,\"User\":\"andrew\"}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:45.9) Gecko\/20100101 Goanna\/3.2 Firefox\/45.9 PaleMoon\/27.2.1","version":"12.0.0.16"}
{"reqId":"ZGcP4vsGV0MbQvdtSsFh","level":4,"time":"2017-05-03 12:17:36","remoteAddr":"172.19.0.1","user":"andrew","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/Documents\/Books\/RPG\/7th%20Sea\/NationsofTheah_Vol1_LowRes_DT_2017_04_14.pdf","message":"Exception: {\"Message\":\"HTTP\\\/1.1 400 expected filesize 17713100 got 15310848\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\BadRequest\",\"Code\":0,\"Trace\":\"#0 \\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(149): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->put(Resource id #11)\\n#1 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1095): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->createFile('NationsofTheah_...', Resource id #11)\\n#2 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(525): Sabre\\\\DAV\\\\Server->createFile('Documents\\\/Books...', Resource id #11, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#6 \\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/nextcloud\\\/remote.php(162): require_once('\\\/nextcloud\\\/apps...')\\n#9 {main}\",\"File\":\"\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":151,\"User\":\"andrew\"}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:45.9) Gecko\/20100101 Goanna\/3.2 Firefox\/45.9 PaleMoon\/27.2.1","version":"12.0.0.16"}
{"reqId":"3XJP3GQ2Pi4nuS9YtXUH","level":3,"time":"2017-05-03 12:20:08","remoteAddr":"172.19.0.1","user":"admin","app":"index","method":"GET","url":"\/apps\/files\/index.php\/apps\/gallery\/config?extramediatypes=1","message":"Exception: {\"Exception\":\"Exception\",\"Message\":\"The requested uri(\\\/apps\\\/files\\\/index.php\\\/apps\\\/gallery\\\/config) cannot be processed by the script '\\\/apps\\\/gallery\\\/config')\",\"Code\":0,\"Trace\":\"#0 \\\/nextcloud\\\/lib\\\/base.php(928): OC\\\\AppFramework\\\\Http\\\\Request->getRawPathInfo()\\n#1 \\\/nextcloud\\\/index.php(40): OC::handleRequest()\\n#2 {main}\",\"File\":\"\\\/nextcloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Request.php\",\"Line\":729}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:45.9) Gecko\/20100101 Goanna\/3.2 Firefox\/45.9 PaleMoon\/27.2.1","version":"12.0.0.16"}

Browser log


Browser log

No errors present in browser log.

needs info

Most helpful comment

This would be fixed by making the web ui support chunked and resumeable upload. This is by far the most wanted feature by me and my colleagues.

All 10 comments

I'm absolutely no expert here, but it sounds more like a server configuration error than a Nextcloud error (especially since it was the same behavior on 11.X as well), but I might be wrong.

What is your upload max setting in PHP? Is this server behind a proxy?

upload_max_filesize is 10 gigabytes. The container is behind Caddy being used as a reverse proxy with the following settings:

nebula.logomancy.net {
    proxy / localhost:[port redacted] {
        transparent
    }
    tls [email redacted]
}

Ok, I use a reverse proxy too, and before I figured out that I needed to bypass the proxy and upload directly to the backend I had similar issues as you - the uploads would just stop.

I use Nginx as a reverse proxy and I had to add a setting in my Nginx conf so that all the files that where uploaded was sent directly to my Apache backend, and in Apache I created a upload-tmp dir where all the files ended up.

That solved my issue anyway. Never touched Nebula (heard it's neat though) so I can't help you there, but start investigating your settings. That's what I would do to find out where it stops and why.

I wrote a blog post about increasing max size here: https://www.techandme.se/increase-max-file-size/

This would be fixed by making the web ui support chunked and resumeable upload. This is by far the most wanted feature by me and my colleagues.

@cowai Would be great, indeed.

Nebula's just my name for the instance; I'm not actually using Nebula.

Investigating my settings, I don't see caddy doing any sort of buffering. There's buffering on php-fpm's end, but I tried turning that off and it didn't seem to have any effect.

@cowai see the issue for chunking at https://github.com/nextcloud/server/issues/673 – any contribution is very welcome! :)

same issue with nextcloud 12 and caddy. All was ok with same caddy config and v11

I have upgraded caddy and problem has gone.

Let's focus on the chunked upload for now and for setup issues ask in the forums: https://help.nextcloud.com

Was this page helpful?
0 / 5 - 0 ratings