我需要通过 ServiceStack 服务运行 1 次长时间运行的操作(大约 10 分钟)。我在本地计算机上运行这一切,ServiceStack 在 IIS 和 .NET 5 上运行。现在它给出了超时,我不知道是什么原因(顺便检查了我的 IIS 设置)。我的部分代码(我删除了一些不相关的代码):
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);
}
这是一个例外:
System.Net.WebException:“操作已超时。”
此异常最初是在此调用堆栈中引发的: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) 在 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() ... [调用堆栈被截断]