3

We use Service stack, and run using the InProcess model on .net core.

We have some longer running requests, which we would like to timeout - however, I am struggling to do this. Before .net core, you could configure the httpRuntime's "executionTimeout" however, this is unavailable in .net core. The new way of doing this (I believe) is to use the "requestTimeout" in the config - but Microsoft's website claims this is not supported with the InProcess model. If feels like the only solution left is to configure this in Service Stack somewhere, but I am not seeing anywhere obvious.

Am I missing something here? Is there a ServiceStack option to force the thread to finish on a timeout, or is this just not not possible?

There are other timeout options via IIS, but none which will stop the execution

Thanks

David Hiblen
  • 255
  • 3
  • 13

1 Answers1

0

ServiceStack operates as a library handler on the .NET HTTP Worker Request thread, i.e. it doesn't spawn or manage any of its own threads. Any request quota limits or timeouts would need to be configured on the underlying HTTP Server, i.e. just as any other ASP.NET Core App would need to do.

If you're using IIS, you can still configure ASP.NET Core Request Timeouts in Web.config in the <aspNetCore/> tag. If you're using the default Kestrel HTTP Server you can configure its limits when configuring your Web Host.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • But if you are using In Process model with .net core 3.1 the `requestTimeout` [will not work](https://learn.microsoft.com/en-gb/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1#in-process-hosting-model). Would you therefore have to implement this via middleware? – strickt01 Jan 29 '21 at 14:37
  • @strickt01 Given one of the primary ASP .NET Core authors suggests [it would be difficult to implement via middleware](https://stackoverflow.com/a/52660992/85785) I wouldn't recommend it. Don't know if there is an optimal solution, maybe you could run long running requests in a new Thread then cancel that. – mythz Jan 29 '21 at 15:04
  • Unfortunately, the inprocess model ignores the request timeouts ( https://github.com/dotnet/aspnetcore/issues/23160 ) so we are stuck until we move to Kestrel. Thanks for your help mythz - was afraid that would be the answer – David Hiblen Jan 29 '21 at 16:20