Amazon Web Service S3 timed out
<p>I am using <code>S3 bucket</code> to upload image from my <code>swift</code> project, however, every now and then my upload pauses and gives me the following warning in console. However, I am not sure why but the upload appears to automatically restart and the second time almost always succeeds. And any upload after that is normally fine. (It is only when I have not interacted with the server for awhile</p>

<pre><code>AWSiOSSDK v2.4.7 [Error] AWSURLSessionManager.m line:212 | -[AWSURLSessionManager URLSession:task:didCompleteWithError:] | Session task failed with error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x13eba2b50 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https://s3.amazonaws.com/myBucketName/filename.jpg, NSErrorFailingURLKey=https://s3.amazonaws.com/myBucketName/filename.jpg, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
</code></pre>

<p><strong>Below is how I send file to S3</strong></p>

<pre><code>    // 2. Create upload request
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.bucket = "myBucket"
uploadRequest.key = "FileName.jpg"
uploadRequest.ACL = AWSS3ObjectCannedACL.PublicRead
uploadRequest.contentType = "image/jpg"
uploadRequest.body = url


// Track progress through an AWSNetworkingUploadProgressBlock
uploadRequest?.uploadProgress = {[weak self](bytesSent:Int64, totalBytesSent:Int64, totalBytesExpectedToSend:Int64) in
    dispatch_sync(dispatch_get_main_queue(), { () -&gt; Void in

        let progress = Float(totalBytesSent) / Float(totalBytesExpectedToSend)

        print(" totalBytesSent \(totalBytesSent) / totalBytesExpectedToSend \(totalBytesExpectedToSend) progress = \(progress * 100 ) %")

        circularProgressView.setProgress(progress, animated: true)

    })
}

// 3. Upload to Amazone S3
let transferManager = AWSS3TransferManager.defaultS3TransferManager()
transferManager.upload(uploadRequest).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: { (task: AWSTask) -&gt; AnyObject? in

    MRProgressOverlayView.dismissOverlayForView(self.view, animated: true)
    self.enableUserInteraction()

    if let error = task.error {

        if error.domain == AWSS3TransferUtilityErrorDomain {

            switch task.error?.code {
            case AWSS3TransferManagerErrorType.Cancelled.rawValue?:
                break
            case AWSS3TransferManagerErrorType.Paused.rawValue?:
                break
            default:
                self.showErrorAlert("Error uploading image #1", message: "\(error)")
            }
        } else {
            self.showErrorAlert("Error uploading image #2", message: "\(error)")
        }

    } else {

        if task.completed {
            let imgLink = "https://s3.amazonaws.com/letzzeeamazones3bucket2/\(uploadRequest.key!)"
            self.postToFirebase(imgLink, userCoordinate: userCoordinate)

        } else {
            self.showErrorAlert("Error uploading image #3", message: "Please try again later")
            MRProgressOverlayView.dismissOverlayForView(self.view, animated: true)
            self.enableUserInteraction()
        }
    }
</code></pre>