Error when assembling chunks. Status code 504 on big file upload

My setup:
All services run on my raspberry pi, started with docker-compose (given with used images)
Nextcloud 20.0.2 - nextcloud:latest
nginx - alexanderkrause/rpi-nginx-proxy:latest
letsencrypt - alexanderkrause/rpi-letsencrypt-nginx-proxy-companion:latest
MariaDB - jsurf/rpi-mariadb:latest

The issue you are facing:
I want to upload a file with 4.4 GB (over web interface or windows client - does not matter) and the upload goes through. At the end I get the error “Error when assembling chunks. Status code 504”. When I upload the file with the windows client a file gets created in nextcloud, but it is a little bigger than 400MB and not the total 4.4 GB.

Is this the first time you’ve seen this error?
Yes, but I never uploaded such a big file before.

The output of your Nextcloud log in Admin > Logging:
I can not find a directly related log entry. Same story with “docker logs nextcloud”. In Admin > Logging I fond the following:

[webdav] Fatal: Sabre\DAV\Exception: Error while copying file to target location (copied bytes: -1, expected filesize: -1 ) at <<closure>>

 0. /var/www/html/apps/dav/lib/Connector/Sabre/Directory.php line 155
    OCA\DAV\Connector\Sabre\File->put(null)
 1. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 311
    OCA\DAV\Connector\Sabre\Directory->createFile("complete_dataset.csv", null)
 2. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 135
    Sabre\DAV\Tree->copyNode(OCA\DAV\Upload\FutureFile {}, OCA\DAV\Connector\Sabre\Directory {}, "complete_dataset.csv")
 3. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 167
    Sabre\DAV\Tree->copy("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 4. /var/www/html/apps/dav/lib/Upload/ChunkingPlugin.php line 95
    Sabre\DAV\Tree->move("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 5. /var/www/html/apps/dav/lib/Upload/ChunkingPlugin.php line 77
    OCA\DAV\Upload\ChunkingPlugin->performMove("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 6. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    OCA\DAV\Upload\ChunkingPlugin->beforeMove("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 7. /var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 632
    Sabre\DAV\Server->emit("beforeMove", ["uploads/Tobias ... "])
 8. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpMove(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
 9. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:MOVE", [Sabre\HTTP\Requ ... }])
10. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
11. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
12. /var/www/html/apps/dav/lib/Server.php line 332
    Sabre\DAV\Server->exec()
13. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
14. /var/www/html/remote.php line 167
    require_once("/var/www/html/a ... p")

MOVE /remote.php/dav/uploads/Tobias/web-file-upload-34b6609342212e629dd8ed1f7973a0db-1606827345313/.file
from 172.80.0.2 by Tobias at 2020-12-01T13:11:10+00:00

What I already tried:

  1. nginx container - /etc/nginx/nginx.conf
    added the following lines in http segment:
client_max_body_size 0;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
  1. nextcloud container - added file in /usr/local/etc/php/conf.d/tweak.ini with content:
request_terminate_timeout=3600
post_max_size = 100G
upload_max_filesize = 100G
max_execution_time=3600

No success…

I really hope someone can help me here! :slight_smile:
Thanks in advance!

1 Like

I have the same behaviour, same settings. Try everythings, but nothing achieved. Hope someone could help us!

@josmellop

I have a solution, but maybe not in a way you expected.

My nextcloud docker container is now on version 20.0.4. Recently I switched from nginx to traefik v2. Now the upload went through and everything works. My nextcloud container still has the settings mentioned above.

So if you want to keep your nginx I think you have to search for the problem there. Good luck!

If you could point me to a proper tutorial for switching to Traefik v2, because I’m a bit lost :frowning:

I don’t know any good tutorial, because I knew traefik from work. But here are a few hints:

I use the official traefik 2 docker image. Put traefik and nextcloud in the same docker network. Now use traefik with these commands and these labels:

command:
  - "--providers.docker=true"
  - "--providers.docker.exposedbydefault=false"
  - "--entrypoints.web.address=:80"
  - "--entrypoints.web.http.middlewares=redirect-to-https@docker" # use middleware defined in labels. Always redirect http to https
  - "--entrypoints.websecure.address=:443"
  - "--serverstransport.insecureskipverify=true"
  - "--certificatesresolvers.letsencrypt.acme.email=your@mail.com"
  - "--certificatesresolvers.letsencrypt.acme.storage=acme.json"
  - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
 #  - "--certificatesresolvers.letsencrypt.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory" use this for testing. Letsencrypt as a ratio limit on its production endpoint
 # - "--log.level=DEBUG"
 # - "--accesslog=true" help with finding errors
labels:
  - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
  - "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true"

and now you add these labels to your nextcloud container:

    labels:
  - "traefik.http.middlewares.nextcloud_headers.headers.stsSeconds=315360000" # for security mentioned in server overview
  - "traefik.http.middlewares.calcarddav.redirectregex.permanent=true"
  - "traefik.http.middlewares.calcarddav.redirectregex.regex=https://(.*)/.well-known/(card|cal)dav"
  - "traefik.http.middlewares.calcarddav.redirectregex.replacement=https://$$1/remote.php/dav/" # important für caldav and carddav
  - "traefik.enable=true"
  - "traefik.http.routers.nextcloud_http.rule=Host(`example.com`)"
  - "traefik.http.routers.nextcloud_http.entrypoints=web"
  - "traefik.http.routers.nextcloud_https.rule=Host(`example.com`)"
  - "traefik.http.routers.nextcloud_https.entrypoints=websecure"
  - "traefik.http.routers.nextcloud_https.middlewares=calcarddav,nextcloud_headers"
  - "traefik.http.routers.nextcloud_https.tls=true"
  - "traefik.http.routers.nextcloud_https.tls.certresolver=letsencrypt" # defined in traefik command

The traefik documentation is pretty good. Just remeber that everything defined in traefiks command area is its static configuration and all labels are a dynamic configuration. This fact caused me confusion many times :smiley:

Good luck!

1 Like