We have an ASP.NET Core 6.0 web api project. I want to configure kestrel limitations cause connections timeout on big transfers or awaits in business logics.
There is my Program.cs configuration for this. But its not working. Connections are closing after one minute.
We using alphine linux for running this backend in kubernetes. There are no settings for nginx. I think it's integrated in .net core packages idk.
builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxConcurrentConnections = 5000;
options.Limits.MaxConcurrentUpgradedConnections = 5000;
options.Limits.MaxRequestBodySize = int.MaxValue;
options.Limits.MaxRequestBufferSize = int.MaxValue;
options.Limits.KeepAliveTimeout = TimeSpan.FromHours(10);
options.Limits.RequestHeadersTimeout = TimeSpan.FromHours(10);
});
There are some UI logs for test:
413 -> Request Body Size is only 5MB btw.
503 -> Connection Timeout in 1 minute.
I got the point.
You should add this lines to your kubernetes.yml Ingress section under the annotations.
apiVersion: ***
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-body-size: 50m
nginx.ingress.kubernetes.io/proxy-connect-timeout: '1200'
nginx.ingress.kubernetes.io/proxy-read-timeout: '1200'
nginx.ingress.kubernetes.io/proxy-send-timeout: '1200'
This increases the size of the request/response bodies of your api running in the kubernetes and connection timeouts. I set 50 mb and 20 minutes, you can edit as you like.