I have a lambda function written in python that runs a signal processing algorithm with data provided by an iOS application.
The iOS app invokes the function successfully, but after a while gets a time out error:
Session task failed with error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x282711350 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask .<6>" ), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://mylambdaURL/invocations, NSErrorFailingURLKey=https://mylambdaURL/invocations, _kCFStreamErrorDomainKey=4}
I invoke the function like this:
lambdaInvoker.invokeFunction("myLambdaName", jsonObject: jsonObject)
.continueWith(block: {(task:AWSTask<AnyObject>) -> Any? in
if( task.error != nil) {
print("Error: \(task.error!)")
lambdaLogs.errors += 1
return nil
}
if let JSONDictionary = task.result as? NSDictionary {
lambdaLogs.responses += 1
}
return nil
})
However, the logs for the Lambda Function don't show any errors, the function runs successfully and even writes in a dynamoDB table without issues. So Lambda isn't timing out, however, the function runs for around 60s.
This error occurs for around half of the times the lambda is invoked.
Any ideas?
EDIT:
I tried increasing the NSURLSession timeout for request doing this in appDelegate:
let urlconfig = URLSessionConfiguration.default
urlconfig.timeoutIntervalForRequest = 300
but I still get the timeouts and the maximum run time for the lambda function was 70s, so I'm thinking I'm not really setting the correct timeoutIntervalForRequest