Sebclem / hassio-nextcloud-backup

Hass.io Add-on: Backup your snapshots to Nextcloud
GNU General Public License v3.0
118 stars 15 forks source link

Upload Code 201 but 0 bytes and/or HTTPError Response code 500 #211

Closed Shariner closed 10 months ago

Shariner commented 10 months ago

This issue is just created to provide a self found solution.

My logs looked like this for a 500 error:

[2023-08-09 18:40:28] [error]:  HTTPError: Response code 500 (Internal Server Error)
    at Request._onResponseBase (file:///opt/nextcloud_backup/node_modules/got/dist/source/core/index.js:684:31)
    at Request._onResponse (file:///opt/nextcloud_backup/node_modules/got/dist/source/core/index.js:743:24)
    at ClientRequest.<anonymous> (file:///opt/nextcloud_backup/node_modules/got/dist/source/core/index.js:761:23)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at HTTPParser.parserOnIncomingClient (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
    at TLSSocket.socketOnData (node:_http_client:534:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)

Or like this for a 201 error: [2023-07-11 13:58:27] [info]: ...Upload finish ! (status: 201)

The uploaded files had a filesize with 0 bytes or just canceled the upload.

My nextcloud instance in running on apache2. My uploaded files had a filesize of 1.6 GB

Shariner commented 10 months ago

For nextcloud you have to configure php settings:

upload_max_filesize=256G
post_max_size=256G

Explanation: In this example it's set to 256 GB, choose whatever you want. )

if nextcloud is running at nginx you have to set client_max_body_size 0

if nextcloud is running at apache2 you have to set

LimitRequestBody 0
FcgidMaxRequestLen 1073741824

Explanation: LimitRequestBody 0 disables the Limit FcgidMexRequestLen is set in Bytes. In this example 5GB.

As I am running nextcloud at apache2, I confirm these settings for uploading backups to nc with a size up to 5GB. It could be, that the FcgidMaxRequestLen is also missing at nginx servers or has a very similar setting. Check your apache2/Nginx logs, they are very helpful. In my case, the usual upload max request lenght was set to 1GB. Now it's set to 5GB.

Uploads via frontend and/or client is not the same way as uploading via your HA instance, as the frontend chunks bigger uploads and the client uses a different connection type.

The addon is working, if nextcloud has the correct settings - i bet that's a solution for most of the open issues in this repo.