gpt4 book ai didi

asp.net - 无法从传输连接读取数据: Operation canceled

转载 作者:行者123 更新时间:2023-12-04 15:05:36 29 4
gpt4 key购买 nike

我们有一个 .NET WorkerService 在后台运行,等待事件中心的触发器将数据推送到 API Web 服务,但我们遇到了此问题:

有什么想法可能导致这种情况吗?

​​​​ExceptionSource: "System.Net.Http", ExceptionType: "System.Threading.Tasks.TaskCanceledException: The operation was canceled. 

System.IO.IOException: Unable to read data from the transport connection: Operation canceled.

System.Net.Sockets.SocketException (125): Operation canceled

End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Security.SslStream.<FillBufferAsync>g__InternalFillBufferAsync|215_0[TReadAdapter](TReadAdapter adap, ValueTask`1 task, Int32 min, Int32 initial)
at System.Net.Security.SslStream.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
at System.Net.Http.HttpConnection.FillAsync()
at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)

--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Client.MyClient.UpdateAsync(DataRequestUpdate DataRequest, CancellationToken cancellationToken) in /src/Client/Client.cs:line 1232
at Client.Repository.Update(Request data) in /src/Client/Repository.cs:line 32
at WorkerService.EventProcessor.Update(UpdateRequest request) in /src/WorkerService/EventProcessor.cs:line 390", Message: "The operation was canceled." }​

最佳答案

默认的 .NET httpclient 超时是 100 secs 。如果你的客户端花费的时间超过100秒,就会导致上述错误。要解决此问题,只需增加超时值即可。

HttpClient httpClient = new HttpClient(); 
httpClient.Timeout = TimeSpan.FromMinutes(10); //Eg. 10mins timeout

关于asp.net - 无法从传输连接读取数据: Operation canceled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66209674/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com