'Timeout calling long running AWS Lambda aspnetcore
I have a long running lambda (sometimes 10+ minutes) and I call it in this manner
using (var lambdaClient = new AmazonLambdaClient(AWSOptions.Credentials(),new AmazonLambdaConfig
{
Timeout = TimeSpan.FromSeconds(1000)
}))
{
InvokeRequest invoke = new InvokeRequest()
{
FunctionName = functionName,
InvocationType = InvocationType.RequestResponse,
Payload = JsonConvert.SerializeObject(payload)
};
var invokeResponse = await lambdaClient.InvokeAsync(invoke);
if (invokeResponse == null)
return null;
using (var sr = new StreamReader(invokeResponse.Payload))
{
return new TriggerLambdaResponse()
{
StatusCode = invokeResponse.HttpStatusCode,
Payload = await sr.ReadToEndAsync()
};
}
}
and I get exceptions from the InvokeAsync line after less than 1000 seconds (or 15 minutes)
Exception:{ ClassName:System.Threading.Tasks.TaskCanceledException Message:The operation was canceled. Data:null InnerException:{ ClassName:System.IO.IOException Message:Unable to read data from the transport connection: Operation canceled. Data:null InnerException:{ ClassName:System.Net.Sockets.SocketException Message:Operation canceled
From what I understand the lambda still continues its function while the calling code is timing out. I am running on docker aspnetcore 2.2 in linux. Is there any other defaulted timeout I should set? I can see the AWS sdk is using the httpconnection class but I don't have access to its parameters. Any ideas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
