Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

c# - ServiceStack based REST service gives timeout for log running process

I need to run a 1-time long-running operation (around 10 minutes) via a ServiceStack service. I run this all on my local machine with ServiceStack running on IIS and .NET 5. Now it gives a timeout and I have no clue what is the cause (I also checked my IIS settings by the way). Part of my code (I removed some not relevant code):

static async Task Main(string[] args)
{
   var jsonServiceClient = new JsonServiceClient("http://localhost/services");
   jsonServiceClient.Timeout = TimeSpan.FromMinutes(20);
   await CorrectCreationDates(jsonServiceClient);
}

private static async Task CorrectCreationDates(JsonServiceClient jsonServiceClient)
{
   var request = new CorrectCreationDatesRequest();
   var result = await jsonServiceClient.PostAsync(request);
}

This is the exception:

System.Net.WebException: 'The operation has timed out.'

This exception was originally thrown at this call stack: ServiceStack.AsyncServiceClient.SendWebRequestAsync(string, string, object, System.Threading.CancellationToken, bool) in AsyncServiceClient.cs System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.GetResult() Gloneco.Importer.Program.CorrectCreationDates(ServiceStack.JsonServiceClient) in Program.cs System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.GetResult() ... [Call Stack Truncated]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ServiceStack doesn't impose any request limits itself, any limits are imposed by the underlying HTTP Server, e.g. if you're using IIS checkout the How to increase request timeout in IIS answers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...