Code=-1005 "The network connection was lost."
Describe the bug
I start uploading some images to AWS using AWSS3TransferUtility.s3TransferUtility.uploadData..., during the uploading I'm locking the phone, waiting few seconds, after that I unlock the phone and when the app is in foreground I receive the following error in the console:
Task <DDA194A2-74FE-40CC-84C2-1E7B68D6496E>.<22> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x12d993310 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x132f67e30 [0x2181a81b8]>{length = 16, capacity = 16, bytes = 0x100201bb3407d9e10000000000000000}, _kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <DDA194A2-74FE-40CC-84C2-1E7B68D6496E>.<22>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <DDA194A2-74FE-40CC-84C2-1E7B68D6496E>.<22>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://beta.domain.com/api/v2/upload, NSErrorFailingURLKey=https://beta.domain.com/api/v2/upload, _kCFStreamErrorDomainKey=1}
To Reproduce Steps to reproduce the behavior:
- Select some images to upload them in S3
- Move the app to background
- Lock the phone
- Wait few seconds
- Unlock the phone
- Move the app to foreground
- Check the debug console
Observed Behavior Upload failed, but I don't get any error in the task utility.
Expected Behavior Continue upload or at least receive the error from Transfer Utility so like that I can remove the object and ask the user to upload again.
Code Snippet
transferUtility?.uploadData(image.jpegData!, bucket: InformationKeeper.awsBucket, key: "\(uid)/\(finalName).jpeg", contentType: "image/jpeg", expression: expression, completionHandler: { (task, error) in self.uploadTask = nil let uploadedMedia = UploadedMedia(fileExtension: "jpeg", fileName: finalName, url: task.request?.url) DispatchQueue.main.async { completion?(nil, .finished(data.media, uploadedMedia)) } }).continueWith(block: { (task) in self.uploadTask = task.result return nil })
Environment(please complete the following information):
-
SDK Version: pod 'AWSElasticLoadBalancing', '2.27.13' pod 'AWSS3', '2.27.13' pod 'AWSCore', '2.27.13'
-
Dependency Manager: Cocoapods
-
Swift Version : 5
-
Xcode Version: 13.4.1 (13F100)
Device Information (please complete the following information):
- Device: iPhone
- iOS Version: 15.6.1
Thanks for opening the issue and the error logs @nastasiupta . We'll look into it and respond on this issue with any updates.
@nastasiupta Apologies for the long delay.
I was not able to reproduce this in the latest 2.33.8 version using the provided code snippet. The files are uploaded and the callback invoked.
Since this issue was created, we've optimized how uploads are handled. Would you be able to confirm if this is still happening for you?
Thanks!