Uploading a file through nextcloud’s web interface timeouts after 60s

The title says all : Uploading a file through the web interface timeouts after 60s

2025-01-24T18:06:49+01:00 [1:nextcloud8:nextcloud-app] NOTICE: PHP message: [nextcloud][no app in context][3] {"reqId":"hxWW6vB8MFTM7XrOwRB2","level":3,"time":"2025-01-24T17:06:49+00:00","remoteAddr":"104.28.40.7","user":"--","app":"no app in context","method":"PUT","url":"/public.php/dav/files/x4HyDdGjyd9PWaf/deck-v1.12.6.tar","message":"{\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\BadRequest\",\"Message\":\"Taille du fichier attendue : 66631680 octets mais taille du fichier lue (depuis le client Nextcloud) et \\u00e9crit (dans le stockage Nextcloud) : 21118976 octets. Cela peut \\u00eatre un probl\\u00e8me de r\\u00e9seau au niveau du client ou un probl\\u00e8me de stockage au niveau du serveur.\",\"Code\":0,\"Trace\":[{\"file\":\"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php\",\"line\":148,\"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\":61,\"function\":\"invokeMethod\",\"class\":\"Sabre\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[{\"__class__\":\"Sabre\\\\HTTP\\\\Request\"},{\"__class__\":\"Sabre\\\\HTTP\\\\Response\"}]},{\"file\":\"/var/www/html/apps/dav/appinfo/v2/publicremote.php\",\"line\":159,\"function\":\"start\",\"class\":\"OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Server\",\"type\":\"->\",\"args\":[]},{\"file\":\"/var/www/html/public.php\",\"line\":107,\"args\":[\"/var/www/html/apps/dav/appinfo/v2/publicremote.php\"],\"function\":\"require_once\"}],\"File\":\"/var/www/html/apps/dav/lib/Connector/Sabre/File.php\",\"Line\":301,\"message\":\"Taille du fichier attendue : 66631680 octets mais taille du fichier lue (depuis le client Nextcloud) et \\u00e9crit (dans le stockage Nextcloud) : 21118976 octets. Cela peut \\u00eatre un probl\\u00e8me de r\\u00e9seau au niveau du client ou un probl\\u00e8me de stockage au niveau du serveur.\",\"exception\":{},\"CustomMessage\":\"Taille du fichier attendue : 66631680 octets mais taille du fichier lue (depuis le client Nextcloud) et \\u00e9crit (dans le stockage Nextcloud) : 21118976 octets. Cela peut \\u00eatre un probl\\u00e8me de r\\u00e9seau au niveau du client ou un probl\\u00e8me de stockage au niveau du serveur.\"}","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","version":"29.0.10.1"}

This looks like that “expected filesize 5160954 got 8192” error referred here : Cannot upload files, error "expected filesize 5160954 got 8192" appears - ℹ️ Support - Nextcloud community

Can anybody have a look at this ? Can’t really find my way to configuration files into those containers, still learning hard how to manage them :grimacing:

1 Like

Enter the nextcloud instance:

runagent -m nextcloud1

Edit config.php:

podman unshare nano $(podman volume inspect nextcloud-app-data --format={{.Mountpoint}})/config/config.php

It’s also possible to change config.php values using occ:

occ config:system:set datadirectory --value /var/www/html/data

To edit PHP-FPM config, see also GitHub - NethServer/ns8-nextcloud: Nextcloud module for NS8

nano zzz_nethserver.conf

To enter the container to edit files there:

podman exec -ti nextcloud-app sh
2 Likes

:crazy_face: au secours !

1 Like

Thanks @mrmarkuz, it’s really helping.

Regarding the timeout problem I tried some fixes but without results until now.

I believe this might be related to a Traefik timeout as reported here : [Bug]: Expected filesize of X bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 0 bytes · Issue #37695 · nextcloud/server · GitHub

I’d like to try to fiddle with those respondingTimeouts parameters (see doc here) but I’m not sure to understand how to edit the nextcloud8.yml file I found into the traefik container (if it’s the right file).

If anybody can help with this ?

1 Like

Hi @pagaille

I do not think it’s the right file, as Nextcloud’s config should be in here:
/home/nextcloud1

Try this:

Enter the environment of the App you want to access. Do this as root of the base system of NS8.

runagent -m nextcloud1

You should be able to use vi to edit the file, or even install nano in that environment.
AFAIK, the containers mostly run alpine based stuff, so use the appropriate commands…

apk update
apk add nano 

I’m not sure, but if I recall correctly, a sudo is not needed.

Hope this helps

My 2 cents
Andy

1 Like

Maybe I wasn’t that clear.

The suggested bugfix is related to the combo Traefik <> Nextcloud. The timeout would occur at the traeffik level, hence the traefik configuration tweak.

Hi @pagaille

You could also use the same conventions to access Traefik…

runagent -m traefik1

vi should be there, else install nano / whatever.

My 2 cents
Andy

That’s what I did. My question was : which file to edit and how to add the respondingTimeouts parameters - I know nothing about traefik :grimacing:

At least on the level of Treafik specific commands I’m on the same level as you…

:slight_smile:

Sorry, I can’t help yet there.

My 2 cents
Andy

1 Like

maybe this example from another application can help you a bit:

Don’t know if it’s the right way:

runagent -m traefik1
podman exec -it traefik vi /etc/traefik/configs/nextcloud1.yml

changing each app instance name according to your setup. Sure there are other ways around it.

2 Likes

In this case it’s possible to edit the configs outside of the container because there’s a volume option mapping the local directory ./configs to the containers /etc/traefik/configs directory, see also ns8-traefik/imageroot/systemd/user/traefik.service at main · NethServer/ns8-traefik · GitHub

runagent -m traefik1

Edit the file configs/nextcloud1.yml:

nano configs/nextcloud1.yml

Add the following on top before http:

entryPoints:
  http:
    address: ":80"
    transport:
      respondingTimeouts:
        readTimeout: "0s"
  https:
    address: ":443"
    transport:
      respondingTimeouts:
        readTimeout: "0s"

Restart traefik: (optional, traffic restart should be avoided and is not needed as explained in the post of @dnutan)

systemctl --user restart traefik

This way traefik starts correctly but I didn’t test if it works in NC…

EDIT:

I can’t reproduce the issue on a Debian VPS, uploading a file in Nextcloud that takes longer than 60s works with and without fix.

3 Likes

just a word of caution to not abuse of traefik restart:

2 Likes

Thanks @mrmarkuz and all. That was exactly the answer I was looking for.

Sadly it doesn’t solve the problem :frowning: . The traefik log shows the very precise 60000ms “timeout” :

2025-01-26T11:23:41+01:00 [1:traefik1:traefik] 217.136.24.126 - - [26/Jan/2025:10:22:41 +0000] "PUT /remote.php/dav/uploads/1b301dd7-2d09-49aa-8abc-9042f91078c1/3352809076/00002 HTTP/1.1" 499 21 "-" "-" 161 "nextcloud8-https@file" "http://127.0.0.1:20000" 60000ms
2025-01-26T11:24:43+01:00 [1:traefik1:traefik] 217.136.24.126 - - [26/Jan/2025:10:23:43 +0000] "PUT /remote.php/dav/uploads/1b301dd7-2d09-49aa-8abc-9042f91078c1/3352809076/00002 HTTP/1.1" 499 21 "-" "-" 200 "nextcloud8-https@file" "http://127.0.0.1:20000" 59976ms
2025-01-26T11:25:32+01:00 [1:traefik1:traefik] 217.136.24.126 - - [26/Jan/2025:10:24:32 +0000] "PUT /remote.php/dav/uploads/1b301dd7-2d09-49aa-8abc-9042f91078c1/1640529122/00009 HTTP/1.1" 499 21 "-" "-" 208 "nextcloud8-https@file" "http://127.0.0.1:20000" 60001ms

Another log line may ring a bell :

2025-01-26T11:28:42+01:00 [1:nextcloud8:nextcloud-nginx] 2025/01/26 10:28:42 [info] 26#26: *6366 client prematurely closed connection while sending request to upstream, client: 217.136.24.126, server: , request: "PUT /remote.php/dav/uploads/1b301dd7-2d09-49aa-8abc-9042f91078c1/1640529122/00009 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "drive.gaillet.be"

That may suggest that the reverse proxy might be the culprit. Still investigating.

Did you use the web interface ? The desktop client doesn’t exhibit that behaviour.
This particular nextcloud instance is a NS7 migrated one. Maybe I should try on a vanilla one ?

1 Like

I used the web interface but in my case it wasn’t a migrated Nextcloud.

Just some ideas:

In the link of your first post, they’re talking about the temp dir which I found isn’t set on NS8, see also Cannot upload files, error "expected filesize 5160954 got 8192" appears - #11 by malbreitenbach - ℹ️ Support - Nextcloud community
Maybe that’s the issue.

Which OS do you use? Is it VPS or local network? If local, do you use port forwarding or reverse proxy to provide the service?

I’m going to test it in LAN on a Rocky later…

Indeed, that also something I noticed. Should I try export TMP=/tmp into the module ?

VPS, Rocky - the reverse proxy I mentioned is the integrated nginx image that lives into the module. Maybe it’ss simply the web server and not are reverse proxy actually.

1 Like

It’s worth a try. You could also edit the config.php directly or use occ:

Get temp dir value:

occ config:system:get tempdirectory

Set temp dir to /var/www/html/data/tmp (untested)

occ config:system:set tempdirectory --value /var/www/html/data/tmp
1 Like
"message":"Temporary directory /var/www/html/data/tmp is not present or writable

What’s the sudo password inside the module btw ?

Using

podman exec -ti nextcloud-app sh

it should be possible to enter the container as root without needing a password to be able to create the directory or set right permissions.

of course. my bad, still forgetting about those context changes :grimacing:

Still that doesn’t solve the problem, it still timeouts after 60s. It is actually making the problem worse since now the “written bytes” is now zero. I chowned the data/tmp folder to www-data though. Not sure it would solve the timeout anyway.

1 Like

!!!

I THINK I may have found something of interest. The bug show when I’m NOT authenticated. I configured a folder for a friend and shared it with write access, gave him the personal link.

It’s only when one use that link that the problem arise. I guess that’s a Nextcloud bug, what do you think?

1 Like