connection reset when upload large file in background with NSURLsession

Hi,


I am using NSURLSessionUploadTask in iOS to upload files (photos and videos) in background to my server via Wi-Fi. The small files are all good, but there is one large file that is about 1GB and it failed to upload.


The error reported from the server side is: "connection reset by peer". It is interesting that after that error, it seems the client is again uploading the file using a new HTTP call, only to hit the same error again later.


My question is: does iOS background upload task always upload via a single HTTP POST regardless file size? or possibily via multiple HTTP POST depends on the file size?


Thanks.

does iOS background upload task always upload via a single HTTP POST regardless file size? or possibily via multiple HTTP POST depends on the file size?

NSURLSession
does a single HTTP request for every upload task you issue. It does not automatically fragment uploads because there’s just no standard way to do that. Nor is there any standard way to resume on upload from where it left off. If you’re uploading 1 GB files, you’ll need to work with your server team to come up with your own custom strategy for making progress in the presence of failures.

The error reported from the server side is: "connection reset by peer".

It might be worth investigating what’s happening on the ‘wire’ here. You can use a packet trace to see why this upload has failed.

However, that does not obviate my previous point. Even if you resolve this specific issue, network failures are a fact of life and, if you’re uploading 1 GB files, you’re extremely vulnerable to such failures.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
connection reset when upload large file in background with NSURLsession
 
 
Q