android
android copied to clipboard
File transfer from Android app gets interrupted always for a specific file with expected and actual content length mismatch on server logs
⚠️ Before posting ⚠️
- [x] This is a bug, not a question or an enhancement.
- [x] I've searched for similar 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.
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
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
The PUT Request starts with a 'Content-Length' and it matches with the Expected Content-Length in the Server logs.
However, the PUT Request does not complete full transmission of data and the Server complains with Bad Request
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)
Also I'll be happy to provide any logs on the Server side but any information gathering on the phone will be limited with the facts that I cannot root my phone or install anything apart from Google Play.
Looks like:
nextcloud/android-library#1724 nextcloud/android-library#1727