AWS Ec2 .net 5 return 504 for long running request

Viewed 37

I have a dedicated EC2 server and there is a docker containerized .net 5.0 web API served on it. When I try to send long-running requests I get 504 Gateway Timeout after 90 seconds and I can see that requests end after 120 seconds on the logs in cloudwatch. Is there any EC2 configurations for timeout?

I have added the following codes to Program.cs and Startup.cs

//Program.cs
Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
                webBuilder.ConfigureKestrel(o => { o.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(10);
                    o.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(10);      
                });
            });
 //Startup.cs
services.Configure<FormOptions>(options =>
        {
            options.ValueCountLimit = int.MaxValue;
            options.ValueLengthLimit = int.MaxValue;
            options.MultipartBodyLengthLimit = long.MaxValue;
            options.MultipartBoundaryLengthLimit = int.MaxValue;
            options.MultipartHeadersCountLimit = int.MaxValue;
            options.MultipartHeadersLengthLimit = int.MaxValue;
            options.MemoryBufferThreshold = int.MaxValue;
        });
0 Answers
Related