BadRequest Expected filesize of x bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) y bytes.

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

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:

The Basics

  • Nextcloud Docker installation:
    • nextcloud:latest
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    environment:
      TZ: ${TZ:-Europe/Athens}
      PUID: 1000
      PGID: 1000
      MYSQL_HOST: nextcloud-db
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: nextcloud
      REDIS_HOST: nextcloud-redis
      REDIS_HOST_PORT: 6379
      REDIS_HOST_PASSWORD: ${REDIS_PASSWORD}
      PHP_MEMORY_LIMIT: 50G
      PHP_UPLOAD_LIMIT: 50G
      NEXTCLOUD_ADMIN_USER: ${NEXTCLOUD_ADMIN_USERNAME}
      NEXTCLOUD_ADMIN_PASSWORD: ${NEXTCLOUD_ADMIN_PASSWORD}
      NEXTCLOUD_TRUSTED_DOMAINS: ${DOMAIN}
      TRUSTED_PROXIES: 172.16.0.0/12 192.168.0.0/16 10.0.0.0/8 fc00::/7 fe80::/10 2001:db8::/32
      OVERWRITEPROTOCOL: https

Summary of the issue you are facing:

I am trying to upload a single video file (57 MB), through the web client or the desktop client or the android client and I get the error below:

BadRequest Expected filesize of 60096484 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 36290560 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

I 've noticed that the error occurs at around 60-90 seconds

Steps to replicate it (hint: details matter!):

  1. Add file to sync folder / or upload it through the web page
  2. Wait 60 - 90 seconds
  3. Error occurs (BadRequest Expected filesize of…)

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

{"reqId":"z2TnJ5y8TjiZ1loUQLUW","level":3,"time":"2024-12-25T18:32:55+00:00","remoteAddr":"xxxxxxxxxx","user":"xxxxxxxxxx","app":"no app in context","method":"PUT","url":"/remote.php/dav/files/xxxxxxxxxx/xxxxxxxxxx.mp4","message":"Expected filesize of 60096484 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 36290560 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","userAgent":"Mozilla/5.0 (Windows) mirall/3.15.2 (build 20241216) (Nextcloud, windows-10.0.26100 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"30.0.4.1","exception":{"Exception":"Sabre\\DAV\\Exception\\BadRequest","Message":"Expected filesize of 60096484 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 36290560 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","Code":0,"Trace":[{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","line":110,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Server.php","line":43,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":371,"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":19,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":146,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php","Line":259,"message":"Expected filesize of 60096484 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 36290560 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","exception":{},"CustomMessage":"Expected filesize of 60096484 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 36290560 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side."}}

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

PASTE

Web server / Reverse Proxy

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

nextcloud  | xxxxxxxxxx - xxxxxxxxxx[25/Dec/2024:20:53:02 +0200] "PROPFIND /remote.php/dav/files/xxxxxxxxxx/ HTTP/1.1" 207 964 "-" "Mozilla/5.0 (Windows) mirall/3.15.2 (build 20241216) (Nextcloud, windows-10.0.26100 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
nextcloud  | xxxxxxxxxx - xxxxxxxxxx[25/Dec/2024:20:52:11 +0200] "PUT /remote.php/dav/files/xxxxxxxxxx/xxxxxxxxxx.mp4 HTTP/1.1" 400 1197 "-" "Mozilla/5.0 (Windows) mirall/3.15.2 (build 20241216) (Nextcloud, windows-10.0.26100 ClientArchitecture: x86_64 OsArchitecture: x86_64)"

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.locking.timeout": 3600,
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwriteprotocol": "https",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "upgrade.disable-web": true,
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "xxxxxxxxxxxx.com",
            "192.168.2.100"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "30.0.4.1",
        "overwrite.cli.url": "https:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "default_phone_region": "GR",
        "loglevel": 2,
        "maintenance": false,
        "max_execution_time": 3600
    }
}

Apps

Enabled:

  • activity: 3.0.0
  • app_api: 4.0.3
  • bruteforcesettings: 3.0.0
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contactsinteraction: 1.11.0
  • cookbook: 0.11.2
  • dav: 1.31.1
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_downloadlimit: 3.0.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • firstrunwizard: 3.0.0
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • nextcloud_announcements: 2.0.0
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • password_policy: 2.0.0
  • photos: 3.0.2
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recommendations: 3.0.0
  • related_resources: 1.5.0
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • support: 2.0.0
  • survey_client: 2.0.0
  • systemtags: 1.20.0
  • text: 4.1.0
  • theming: 2.5.0
  • twofactor_backupcodes: 1.19.0
  • updatenotification: 1.20.0
  • user_status: 1.10.0
  • viewer: 3.0.0
  • weather_status: 1.10.0
  • webhook_listeners: 1.1.0-dev
  • workflowengine: 2.12.0
    Disabled:
  • admin_audit: 1.20.0
  • dashboard: 7.10.0 (installed 7.9.0)
  • encryption: 2.18.0
  • files_external: 1.22.0
  • suspicious_login: 8.0.0
  • twofactor_nextcloud_notification: 4.0.0
  • twofactor_totp: 12.0.0-dev
  • user_ldap: 1.21.0

Tips for increasing the likelihood of a response

  • Use the preformatted text formatting option in the editor for all log entries and configuration output.
  • If screenshots are useful, feel free to include them.
    • If possible, also include key error output in text form so it can be searched for.
  • Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.

Is this your production Compose file? It doesn’t have any volumes specified for storing data.

I’ve noticed that the error occurs at around 60-90 seconds

What is your typical upload performance? I ask because this may be a simple web server or reverse proxy timeout, particularly since chunking isn’t used by the desktop client for 57M files by default.

Do you have the log output from an attempt via the Web UI? If you upload via the web UI, it should split a 57M file up into 6 chunks (at least in <=v30) unless you’ve changed your chunking settings from the default there (the web UI uses 10M chunk sizes)

Thanks for the reply!

Here is the whole compose

  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    environment:
      TZ: ${TZ:-Europe/Athens}
      PUID: 1000
      PGID: 1000
      MYSQL_HOST: nextcloud-db
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: nextcloud
      REDIS_HOST: nextcloud-redis
      REDIS_HOST_PORT: 6379
      REDIS_HOST_PASSWORD: ${REDIS_PASSWORD}
      PHP_MEMORY_LIMIT: 50G
      PHP_UPLOAD_LIMIT: 50G
      NEXTCLOUD_ADMIN_USER: ${NEXTCLOUD_ADMIN_USERNAME}
      NEXTCLOUD_ADMIN_PASSWORD: ${NEXTCLOUD_ADMIN_PASSWORD}
      NEXTCLOUD_TRUSTED_DOMAINS: ${DOMAIN}
      TRUSTED_PROXIES: 172.16.0.0/12 192.168.0.0/16 10.0.0.0/8 fc00::/7 fe80::/10 2001:db8::/32
      OVERWRITEPROTOCOL: https
    depends_on:
      - nextcloud-redis
      - nextcloud-db
      - traefik
    ports:
      - ${NEXTCLOUD_PORT}:80
      # - 443:443
    volumes:
      - nextcloud:/var/www/html
      - ./nextcloud/redis/redis-session.ini:/usr/local/etc/php/conf.d/redis-session.ini:z
      - ${EXTERNAL_HD1_PATH}/nextcloud-data:/var/www/html/data
      - ${EXTERNAL_HD1_PATH}/media:/media
      - ${EXTERNAL_HD2_PATH}/backup:/backup
      - ${EXTERNAL_HD2_PATH}/samba-data:/samba
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.nextcloud.service=nextcloud"
      - "traefik.http.routers.nextcloud.entrypoints=websecure"
      - "traefik.http.services.nextcloud.loadbalancer.server.port=80"
      - "traefik.http.routers.nextcloud.tls=true"
      - "traefik.http.routers.nextcloud.tls.certresolver=letsencrypt"
      - "traefik.http.services.nextcloud.loadbalancer.passhostheader=true"
      - "traefik.http.routers.nextcloud.middlewares=compresstraefik,traefik-headers,traefik-redirect"
      - "traefik.http.middlewares.compresstraefik.compress=true"
      - "traefik.http.middlewares.traefik-headers.headers.referrerPolicy=no-referrer"
      - "traefik.http.middlewares.traefik-headers.headers.sslRedirect=true"
      - "traefik.http.middlewares.traefik-headers.headers.stsSeconds=315360000"
      - "traefik.http.middlewares.traefik-headers.headers.browserXSSFilter=true"
      - "traefik.http.middlewares.traefik-headers.headers.contentTypeNosniff=true"
      - "traefik.http.middlewares.traefik-headers.headers.forceSTSHeader=true"
      - "traefik.http.middlewares.traefik-headers.headers.stsIncludeSubdomains=true"
      - "traefik.http.middlewares.traefik-headers.headers.stsPreload=true"
      - "traefik.http.middlewares.traefik-headers.headers.customFrameOptionsValue=SAMEORIGIN"
      - "traefik.http.middlewares.traefik-redirect.redirectRegex.permanent=true"
      - "traefik.http.middlewares.traefik-redirect.redirectRegex.regex=https://(.*)/.well-known/(?:card|cal)dav"
      - "traefik.http.middlewares.traefik-redirect.redirectRegex.replacement=https://$${1}/remote.php/dav"
      - "traefik.docker.network=traefik-network"

as well as the traefik compose

  traefik:
    image: traefik:latest
    container_name: traefik
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--serverstransport.insecureskipverify=true"
      - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
      - "--certificatesresolvers.letsencrypt.acme.email=xxxxxxxxx"
      - "--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json"
      # - "--entrypoints.dns_tcp.address=:53"
      # - "--entrypoints.dns_udp.address=:53/udp"
      - "--entrypoints.vpn_udp.address=:51820/udp"
    ports:
      - 80:80
      - 443:443
      # - 53:53/tcp
      # - 53:53/udp
      - 51820:51820/udp
      - ${TRAEFIK_PORT}:8080
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - ./traefik/letsencrypt:/etc/traefik/acme
      - ./traefik/FileProvider/:/FileProvider/
    restart: always

Upload speed is around 5 Mbps

Web ui logs

image

chunks fail with same error

{"reqId":"nV5ZuLGuMol2sLwgsJZi","level":3,"time":"2024-12-28T08:17:01+00:00","remoteAddr":"xxxxxxxxxx","user":"jkokotinis","app":"no app in context","method":"PUT","url":"/remote.php/dav/uploads/jkokotinis/web-file-upload-f2de8534184e2950/1","message":"Expected filesize of 10485760 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 7266304 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0","version":"30.0.4.1","exception":{"Exception":"Sabre\\DAV\\Exception\\BadRequest","Message":"Expected filesize of 10485760 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 7266304 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","Code":0,"Trace":[{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","line":110,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/dav/lib/Upload/UploadFolder.php","line":34,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Upload\\UploadFolder","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Server.php","line":43,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":371,"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":19,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":146,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php","Line":259,"message":"Expected filesize of 10485760 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 7266304 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.","exception":{},"CustomMessage":"Expected filesize of 10485760 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 7266304 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side."}}

Thanks for your time!

Edit: Uploading a smaller 17MB video on the same folder works without any issues.

I just tested uploading the video from another network with higher upload speed. The video uploads normally, without any issue. So it is not a max upload size configuration. There seems to be a timeout somewhere, that I cannot find and configure. Any ideas?

I tried to upload a 1GB file, both through the web page and the desktop client.

The 1GB file was split in more chunks than the 50mb file. Most chunks took less than 1 minute to upload. Some chunks took more than 1 minute and failed with the BadRequest error, but they were retried on their own and succeeded the second time.

After more than 3 minutes, the file was uploaded, both through the web client and the desktop client.

So the timeout must be somewhere on the chunk upload process and not on the whole file upload process.