C
C#10mo ago
quackquack

❔ How do i set request time out for .NET 6?

public class Program
{
public static void Main(string[] args)
{
//Enable after handling database context
CreateHostBuilder(args).Build().MigrateDatabase().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel(option =>
{
option.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(10);
});
webBuilder.UseStartup<Startup>();
});
}
public class Program
{
public static void Main(string[] args)
{
//Enable after handling database context
CreateHostBuilder(args).Build().MigrateDatabase().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel(option =>
{
option.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(10);
});
webBuilder.UseStartup<Startup>();
});
}
This is my Program.cs, i've tried setting the option.Limits.KeepAliveTimeout to 10s but the request that takes longer than that doesn't just throw up
10 Replies
JakenVeina
JakenVeina10mo ago
you're saying you want the server to reject requests that take longer than 10 seconds to process?
quackquack
quackquack10mo ago
I want to increase the time out for requests to the server @V.EINA Jaken do you know how to increase it? Seems like it only available in .NET 8
JakenVeina
JakenVeina10mo ago
is that a "yes"?
quackquack
quackquack10mo ago
Yes
JakenVeina
JakenVeina10mo ago
that is 100% not what KeepAliveTimeout does, for one
JakenVeina
JakenVeina10mo ago
RFC 9112: HTTP/1.1
The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, collaborative, hypertext information systems. This document specifies the HTTP/1.1 message syntax, message parsing, connection management, and related security concerns.
This document obsoletes portions of RFC 7230....
JakenVeina
JakenVeina10mo ago
for two, there's really no such thing as a server-side request timeout not in general timeouts are about entities waiting on something an HTTP server that has received a request isn't waiting it's processing the request there's an option for how long the server will wait to RECEIVE the request specifically, the request headers
JakenVeina
JakenVeina10mo ago
beyond that, an application that processes requests by doing database I/O might have a timeout for that database I/O that's definitely got nothing to do with HTTP or Kestrel the entity that's doing the waiting, during an HTTP request is the client you can easily configure timeouts there
Accord
Accord10mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.