nextcloud / nextcloud/android

File transfer from Android app gets interrupted always for a specific file with expected and actual content length mismatch on server logs

Open
#14,950 2 comments 0 reactions 0 assignees View on GitHub
0. Needs triage bug
Dominant language
Kotlin
Stars
5.6k
Forks
2k
Avg merge
2d 18h
Merged PRs (30d)
92

Description

### ⚠️ Before posting ⚠️

- [x] This is a **bug**, not a question or an enhancement.
- [x] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [x] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [x] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).

### Steps to reproduce

Unable to upload a file using Android client and self hosted nextcloud server on raspberry pi 4. The Android client shows the file as mostly uploaded and then errors out. The file in question is ~30MB and this always happens for the file.

The nextcloud log:

`{"reqId":"RcUuEYBJeligSAKSSE5d","level":3,"time":"2025-06-02T21:11:23+00:00","remoteAddr":"192.168.0.136","user":"sisir","app":"no app in context","method":"PUT","url":"/nc/remote.php/dav/uploads/sisir/9899705e61bf428e2b83d3b1fb9085f2/000001","message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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 (Android) Nextcloud-android/3.31.3","version":"31.0.5.1","exception":{"Exception":"Sabre\\DAV\\Exception\\BadRequest","Message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":116,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Upload/UploadFolder.php","line":28,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Upload\\UploadFolder","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Server.php","line":49,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":400,"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":21,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":145,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","Line":255,"message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side."}}
`

### Expected behaviour

Expected behavior is that the file should be uploaded correctly.

### Actual behaviour

Actual behavior is that the file errors out mid-way with 'Connection Error' on the Android Client.

### Android version

14

### Device brand and model

One Plus Nord CE 3 5G

### Stock or custom OS?

Stock

### Nextcloud android app version

3.31.3

### Nextcloud server version

NextCloud Hub 10(31.0.5)

### Using a reverse proxy?

No

### Android logs

This is release version and I couldnt find a way to get logs.

### Server error logs

```bash
Only one snippet gets generated for the erring file on the server.

{"reqId":"RcUuEYBJeligSAKSSE5d","level":3,"time":"2025-06-02T21:11:23+00:00","remoteAddr":"192.168.0.136","user":"sisir","app":"no app in context","method":"PUT","url":"/nc/remote.php/dav/uploads/sisir/9899705e61bf428e2b83d3b1fb9085f2/000001","message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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 (Android) Nextcloud-android/3.31.3","version":"31.0.5.1","exception":{"Exception":"Sabre\\DAV\\Exception\\BadRequest","Message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":116,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Upload/UploadFolder.php","line":28,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Upload\\UploadFolder","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Server.php","line":49,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":400,"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":21,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":145,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","Line":255,"message":"Expected filesize of 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 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 31232001 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 31227904 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side."}}
```

### Additional information

To debug this, I took a TCP dump and here are the observations

The Server responds with a Bad Request

![Image](https://github.com/user-attachments/assets/f14cd34e-0a40-4cc6-a8a5-9f29cf2ecd1d)

The PUT Request starts with a 'Content-Length' and it matches with the Expected Content-Length in the Server logs.

![Image](https://github.com/user-attachments/assets/3d728168-6885-499b-9574-017fa20a4a54)

However, the PUT Request does not complete full transmission of data and the Server complains with Bad Request

![Image](https://github.com/user-attachments/assets/c3bd1d46-5d06-40b4-b3fe-f2ec457cbea4)

In TCP dump, we see a stoppage of data from Client Side with the last packet from Server to Client at 4.9593115 and the Client initiating a Fin Ack at 44.336959. (approximately 40 seconds later)

![Image](https://github.com/user-attachments/assets/8c6fd42b-eeef-4f3e-8808-13e2ce1007d2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.