nextcloud / ios

📱 Nextcloud iOS App
https://itunes.apple.com/us/app/nextcloud/id1125420102
GNU General Public License v3.0
1.94k stars 875 forks source link

413 error when uploading file from iOS client #396

Closed ntompson closed 3 years ago

ntompson commented 6 years ago

Since upgrading to iOS 11 (11.0.2), I have found that the iOS NextCloud client is unable to upload "large" files - in my example, an 11 MB PDF file is failing to upload, with error "413" reported. I have no problem uploading the same file via the desktop client (Mac).

I am not seeing any corresponding entries in the server side log (via the NextCloud web-admin console).

I have experienced this problem on both iPhone 6 plus and iPad Pro (big one, first version). Both are at iOS 11.0.2 and have the latest NextCloud app.

I am initiating the upload using the "share sheet" in Safari with the PDF loaded in the browser. See screen shots.

img_1913 img_1914 img_1915

rkratochvil commented 5 years ago

I sent an email to iOS at Nextcloud. They attempted to upload a 100mb file and ran into the issue we are all talking about here to my server. They said “Yup, doesn’t work. Issue is on your side”. I responded back stating that everything works just fine if you log in through a web browser and asked for additional information. I haven’t heard anything back. Once again that’s fine if there’s an issue with some setting server-side with the iOS app, but I want to know what setting that is. I’m struggling with the fact that this seems to work for everything BUT the iOS app yet the issue is with all of our configurations, not the iOS app.

netpanda commented 5 years ago

I sent an email to iOS at Nextcloud. They attempted to upload a 100mb file and ran into the issue we are all talking about here to my server. They said “Yup, doesn’t work. Issue is on your side”. I responded back stating that everything works just fine if you log in through a web browser and asked for additional information. I haven’t heard anything back. Once again that’s fine if there’s an issue with some setting server-side with the iOS app, but I want to know what setting that is. I’m struggling with the fact that this seems to work for everything BUT the iOS app yet the issue is with all of our configurations, not the iOS app.

yeap.. they doesnt seem to care on explaining why the iOS app is the only part that doesnt work..

ArnaudFeld commented 5 years ago

@marinofaggiana It is a Bug of the iOS App!!! Same File to the Same Server with the AndroidApp works. So what could it be?

marinofaggiana commented 5 years ago

@ArnaudFeld , I think that Android App use the chunk , correctly @tobiasKaminsky ?

tobiasKaminsky commented 5 years ago

@marinofaggiana yes, we do use chunked upload for files > 1Mb. This is the doc: https://docs.nextcloud.com/server/stable/developer_manual/client_apis/WebDAV/chunking.html

marinofaggiana commented 5 years ago

yes, @ArnaudFeld as you see this is the difference, but this is not an issue of client.

p.s. this is in todo but is not an priority

ArnaudFeld commented 5 years ago

But why is the way of uploading different between Android-and iOS-App?

What is for you the issue? The Server?

ArnaudFeld commented 5 years ago

yes, @ArnaudFeld as you see this is the difference, but this is not an issue of client.

Then what is the Issue? Why is the Android (in this case) without Problem? WHY???

JPBoero commented 5 years ago

Please check that the data is sent as multipart and the boundaries are correct, otherwise, when sending as application/json the string will go on the URL and you will get 413, because a PDF or other big thing will produce too many strings to go on the URL.

ArnaudFeld commented 5 years ago

@JPBoero And how do i this?

Why did the Android Version of the App works and the iOS Version Not?

jospoortvliet commented 5 years ago

Hi all, I understand the frustration with upload issues, but please understand we work as hard as we can but the iOS client is largely done by one person and he has to focus on customer issues as that is how he (well, our company) gets paid... Coding and debugging help is of course very welcome, but besides that I'm afraid there isn't much that can be done. Please try to stay polite and provide debugging info and test accounts!

netpanda commented 5 years ago

@jospoortvliet we do understand times and money issues, but when he said that is not the client and every other client works.. then the least that he could do is to throw us some hints about what the problem is so we can troubleshoot ourselves. Right now the frustration comes from the fact that he is keeping us in the dark for an issue where he seems to have information not present on this thread (e.g Chunked upload?).

I didnt agree when they talked about posting negative reviews on the AppStore, but when you see comments like: "We have over 800.000 users ... maybe the problem is not the iOS ... have you thought about it ?" is kind of inviting you to do it..

marinofaggiana commented 5 years ago

@netpanda if you read all the posts here it says how to increase the possibility of doing bigger uploads, and I repeat that the problem is not iOS but server configuration.

The possibility of using the chunk in iOS has not yet been implemented (the driver still does not allow it) and is currently not a priority.

rkratochvil commented 5 years ago

@jospoortvliet @marinofaggiana I, like many on here, have made the suggested server changes yet continue to have these issues. I’m assuming you guys have a server which is configured and working with the iOS app for 100+mb uploads.

  1. Could you share your server setup and any configuration files which could help the rest of us re-configure our servers appropriately?

  2. Could you create a test login which we can also test uploading larger files?

Thanks.

mattie47 commented 5 years ago

@rkratochvil

My nginx config:

matt@server:~$ cat /etc/nginx/sites-enabled/nextcloud
server {
    server_name  nextcloud.xxxxxxx.com www.nextcloud.xxxxxxx.com;
    client_max_body_size 0;

    access_log  /var/log/nginx/nextcloud_access.log;
    error_log   /var/log/nginx/nextcloud_error.log;

    location / {
        proxy_pass http://localhost:9006/;
        proxy_set_header Host $host;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/xxxxxxxxxxxxxx; # managed by Certbot
    ssl_certificate_key /etc/zxxxxxxxxxx; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

server {
    if ($host = nextcloud.xxxxxxx.com) {
        return 301 https://$host$request_uri;
    }

    if ($host = www.nextcloud.xxxxxxx.com) {
        return 301 https://nextcloud.xxxxxxx.com$request_uri;
    }

    listen       80;
    server_name  nextcloud.xxxxxxx.com www.nextcloud.xxxxxxx.com;
    return 404;
}

As I said, I think I'm no longer having problems with my setup, but I've created a test user if you want to PM me (username at gmail) and try uploading a file you know doesn't work with your server.

Just tried a 1GB file upload and recorded the results with no issues:

2019-05-02 12.01.16 5160.zip

Thanks,

Matt

rkratochvil commented 5 years ago

Thanks to Matt’s help I can confirm that the app works. Hate to say it but it is something with our config’s on our server. I just uploaded a 114mb .MOV file from my iPad using the Nextcloud app. Time to dive into the configs and figure out what’s wrong. I’ll post my findings here. Thank you again @mattie47 for your help. I’m sure I’ll be hitting you up with some questions if that’s ok.

rkratochvil commented 5 years ago

Ok. I got mine working. Let me walk you all through it.

My setup is taken from the linux.io server walkthrough found here: https://blog.linuxserver.io/2017/05/10/installing-nextcloud-on-unraid-with-letsencrypt-reverse-proxy/

Matt had sent me his config and I was comparing them. When I looked at my letsencript config I noticed this:

location / { proxy_pass https://localhost:444/; proxy_max_temp_file_size 10240m; include /config/nginx/proxy.conf; <-----THAT RIGHT THERE }

See that "include"... I looked into that. Sure as s--t it had: client_max_body_size 10m; client_body_buffer_size 128k;

changed that body size to 0 and buffer size to 400m, everything started working perfectly.

So, to people who are running into this issue I cannot stress this enough: Somewhere in some config you most likely have "client_max_body_size 10m". You want to change that to client_max_body_size 0. Depending on your setup this could be in one of many places. For me personally I had to change it in 3 different locations. Best of luck to all. I'll continue watching this issue and help out where I can. I understand how frustrating it can be.

wyxls commented 5 years ago

I have the same issue in my case. (NextCloud 16.0.1 with Nginx reverse proxy, iOS APP 2.23.7.9 on iPhone 8P+iOS 12.3.2)

I tried @rkratochvil's suggestion but I just change "client_body_buffer_size" to 0 in my nginx.conf, not having "client_body_buffer_size".

Then I uploaded plenty of files like lots of small images <40M, 62.9MB .exe, 130.4MB .mkv, 1.12GB .mp4, 4.14GB .ZIP. All files uploaded sucessfully except 4.14GB ZIP failed which was noticed "can't read file".

So it works with big files now. At last, I also added "client_body_buffer_size 5000m" back into nginx.conf but the ZIP still failed to be uploaded.

Hope someone can resolve this.

ChildLearningClub commented 5 years ago

This might be unique to me, but I found that unlike the web client, the ios app was consuming RAM through the nginx reverse proxy buff/cache when uploading larger files. The RAM would run out and then restart the upload in a continues cycle. Adding "proxy_request_buffering off;" in the location block prevented the caching and allowed for the larger files to be uploaded.

location / {
      proxy_request_buffering off;
     }
influenist commented 5 years ago

This bug is present for over 2 years. Movies simply are not being uploaded when having 500MB+ file size! Seems not to be on the server side if I look at this issue report. My server is nginx only, no reverse proxy.

...

influenist commented 5 years ago

I tried uploading from my phone some 400MB videos but had no issues doing so in the app. I then tried doing the exact same steps as @ntompson's first post in safari with a 22M

maybe try a 600 mb file instead, my issue starts from 400 / 500. I read most of the reports here use a docker setup. In my case the server is build on the install instructions with Nginx / Redis.

Please try to reproduce it with a lager file and see if you run into the same issue. Could be one of the Nginx / SSL / php-fpm settings which only applies to the way the iOS client uploads.

influenist commented 5 years ago

This might be unique to me, but I found that unlike the web client, the ios app was consuming RAM through the nginx reverse proxy buff/cache when uploading larger files. The RAM would run out and then restart the upload in a continues cycle. Adding "proxy_request_buffering off;" in the location block prevented the caching and allowed for the larger files to be uploaded.

location / {
      proxy_request_buffering off;
     }

Which config file are you exactly referring to?

marinofaggiana commented 5 years ago

@influenist the chunked upload is in ToDo list but is not urgent. sorry

ChildLearningClub commented 5 years ago

@influenist I apologize for not being more specific. The code I referenced was added to the etc/nginx/sites-enabled file. I added it to the individual "server {" section. I have added my configuration as a reference. Hope that helps. With my specific setup I have the latest Nextcloud docker image running behind nginx as a reverse proxy:

NEXTCLOUD

server { listen 80;

server_name yourserver;
return 301 https://$host$request_uri;

}

server { listen 443 ssl http2;

server_name yourserver;

location = /.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
   return 301 $scheme://$host/remote.php/dav;
}

location / {
    proxy_pass http://yournextcloudcontainerip;
    aio threads;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto https;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_set_header        Host $http_host;
    proxy_intercept_errors  on;
    proxy_set_header   X-Forwarded-Host $server_name;
    proxy_redirect     off;
    proxy_request_buffering off;

}

ssl_certificate     location to your certs
ssl_certificate_key  location to your certs
ssl_protocols      your protocols
ssl_ciphers  your ciphers

}

don't forget to reload or restart nginx for your changes to take affect.

influenist commented 5 years ago

My problem seemed to be resolved by adjusting the max upload size. /etc/ningx/conf.d/nextcloud.conf

    # set max upload size
    client_max_body_size 5G;
    client_body_buffer_size 0;

This resolved the issue. Next to this you can set a max upload size from the Nextcloud administration settings, yet this seems to effect a different config flag.

evan-sm commented 5 years ago

After 2 days of trying to fix this iOS 413 error I found out that CloudFlare is the issue here. Their free tier do not support big chunks of files

Vertux commented 5 years ago

After 2 days of trying to fix this iOS 413 error I found out that CloudFlare is the issue here. Their free tier do not support big chunks of files

This may be one reason, but it is not the main reason for this issue, because e.g. I do not use CloudFlare at all and I run into this error too.

ArnaudFeld commented 4 years ago

@ArnaudFeld , I think that Android App use the chunk , correctly @tobiasKaminsky ?

Hey @marinofaggiana something after this long time that iOS is Using Chunk for Uploading?

roymckenzie commented 4 years ago

I am running NextCloud on a shared hosting server. I do not believe I have the ability to edit the conf file. Is there a configuration solution to solve the 413 error for shared hosting services and iOS?

ArnaudFeld commented 4 years ago

I am running NextCloud on a shared hosting server. I do not believe I have the ability to edit the conf file. Is there a configuration solution to solve the 413 error for shared hosting services and iOS?

The Solution is that the iOS App should make the Upload like the Android App (using Chunk for Upload) but no changes since long time :(

ArnaudFeld commented 4 years ago

Hey @marinofaggiana something after this long time that iOS is Using Chunk for Uploading?

purefan commented 4 years ago

Im currently getting this error, made sure that the nextcloud server allows file uploads of up to 1GB (edited the php values for post_max_size => 1024M and upload_max_filesize => 1024M) but Im still getting a 413 on many files. I also restarted the iOS app and Im running out of ideas, anything else I should check?

marinofaggiana commented 4 years ago

Hi all, the chunk is incompatible with background mode so I can't create this feature, any idea ?

marinofaggiana commented 4 years ago

@Ivansss your opinion?

purefan commented 4 years ago

I would not mind leaving the app running (on the foreground) while uploading large files, for my use case most of my files are under 10MBs and uploading in the background worked fine. For those large files I do not mind to have the app display the badge with the counter for how many files need to be "manually" transferred.

marinofaggiana commented 4 years ago

@purefan yes but I don't know if a file must be uploaded in foreground or in background mode ....  

purefan commented 4 years ago

how about capturing the files that fail to upload with a 413 error code and put them in a separate queue? When pressing the + button, in the "popup" menu with "Upload photos or videos", "Upload file"... there could be an option to "Retry failed uploads", it could go to the same view for the normal Transfers, maybe a message somewhere saying "Retrying failed uploads requires the app to stay open"?

marinofaggiana commented 4 years ago

mmm for the normal user its' incompressible... for example upload a file of 100 MB return error 413, I capture the error and retry with the chunk option of 1MB for file (100 files) so start a new upload for 100 files but when you move the app in background the upload is very very slowly and it may take several hours / days ...the Apple write: for upload in background of several file please create a single zip file for send it in your server. No, send a file chunked in background is not possible.

purefan commented 4 years ago

I mean something like this:

If you want to make it smarter you can keep a variable with the biggest file that was successfully uploaded, and that will tell how big each chunk needs to be.

ArnaudFeld commented 4 years ago

mmm for the normal user its' incompressible... for example upload a file of 100 MB return error 413, I capture the error and retry with the chunk option of 1MB for file (100 files) so start a new upload for 100 files but when you move the app in background the upload is very very slowly and it may take several hours / days ...the Apple write: for upload in background of several file please create a single zip file for send it in your server. No, send a file chunked in background is not possible.

And uploading a file chunked when the app is in foreground? Is that possible?

ArnaudFeld commented 4 years ago

@marinofaggiana is the Idea of @purefan not a solution for the moment?

ghost commented 4 years ago

Hello everyone, I am experiencing this issue. I am running Nextcloud on docker. The video I am trying to upload via the Nextcloud IOS client is 300MB in size.

Here are my config files (relevant content shown): nginx.conf:

client_max_body_size 10G;

uploadsize.conf:

client_max_body_size 10G;
proxy_request_buffering off;

php.ini:

upload_max_filesize = 2048M
post_max_size = 2048M
max_execution_time = 200

I have tried altering both the values of client_max_body_size in both nginx.conf and uploadsize.conf to 0; and then restarting the nginx and fpm containers. I still receive the 413 error in the IOS client.

Any suggestions? Thanks everyone.

EDIT: I am using Cloudflare. I see someone else has identified that Cloudflare is the issue here?

sbouafif commented 4 years ago

EDIT: I am using Cloudflare. I see someone else has identified that Cloudflare is the issue here?

Hello, I have the same problem as you and I'm also using Cloudflare.

I found out Cloudflare has some size limitation on HTTP request : 100MB Free and Pro 200MB Business 500MB Enterprise by default

Their solution is to either:

https://support.cloudflare.com/hc/en-us/articles/200172516-Understanding-Cloudflare-s-CDN

cajuncoding commented 4 years ago

cloudflare

Cloudflare was also the issue for me when using the auto upload camera roll feature, I was continually getting error 413 for failed uploads; it was failing for even relatively small items (images/videos).

FYI by “grey clouded” DNS record, what the Cloudflare documentation (great link above) is referring to is the disabled state of any Cloudflare proxy processing of requests which can improve performance and security. This is done by disabling the proxy status of the DNS record in the DNS tab of Cloudflare.

In my case I have a CName record pointing to my primary DNS entry which has proxy’ing enabled, however by disabling the proxy for that one record that I use for NextCloud (e.g. make it show a “grey cloud” vs “orange cloud” icon) the uploads started to work for me as expected.

MorrisJobke commented 4 years ago

I also ran into this with an 1.05 GB video file. There are two scenarios:

1) I upload from within the app - then the upload dialog just closes without queueing the file. There is no user feedback. It only closes the upload dialog once you click "Upload". 2) If you use the share sheet from the photos app and share to Nextcloud. Then you select the folder and once you click upload you get this not very helpful prompt:

IMG_5785

If it is not working right now, then a proper error would help a lot to avoid confusion of the user.

Also we need to look into a way of fixing this. maybe @Ivansss can help here.

marinofaggiana commented 4 years ago

ops. error do not codified; done in the new driver.

purefan commented 4 years ago

I think @marinofaggiana misunderstood my suggestion. Let me try to explain in a different way:

This would make the upload on the foreground, not on the background, and then it can be chunked

marinofaggiana commented 4 years ago

@purefan thanks for your suggestion but is very complicated this material because the upload/download system under iOS (NSURLSession) are not easily manageable when you start, but soon, I hope, we need rewrite this point and we search a solution ... but you think normal users, and they are 99%, select the file(s) and move the app in background or close the phone, there are no ways to explain the background/foreground/big file chunked, etc. If we choice your suggestion the 99% will complain that it doesn't work; for example when create video and send it via autoupload :-)

tvollscw commented 3 years ago

Getting this error too over Cloudflare while trying to upload any of my videos from a new iPhone. Video is only 350MB, but I get a 413 right away.

No way to upload any videos with my new iPhone on my Nextcloud Server. I have to manually move it over via computer...

tvollscw commented 3 years ago

Any videos over 100MB can't send. Happens across all iOS devices we have trying to sync with our Nextcloud server. This doesn't happen on Android! Can anyone fix this to be like Android?