间歇性HttpClient问题-已处置SslStream

时间:2019-02-02 10:57:03

标签: azure azure-functions dotnet-httpclient

我遇到HttpClient的间歇性问题。它会提前随机处理SslStream。它有时每小时发生一次,有时更频繁。我正在我在Azure上的功能代码,它似乎是完美本地工作,但一旦我在Azure上部署它,它开始出现问题。 我知道HttpClient的隐患,因此我在实现中使用了IHttpClientFactory,它已注入我的API中。

我正在使用微服务,此问题仅影响调用另一个Azure Function应用。

我的HttpClient超时设置为5分钟,Azure Functions超时设置为max。 10分钟,但这没有帮助。

错误消息和堆栈如下:

The operation was canceled.. Inner Exception: The read operation failed, see inner exception.. Cannot access a disposed object.

Object name: 'SslStream'.
   at System.Net.Security.SslStreamInternal.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)
   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.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Huedash.Core.HttpClientService.GetAsync[T](String service, String endpoint, ValueTuple`2[] parameters) in C:\_Huedash\HuedashApiGit\HuedashApiCore\Huedash.Core\HttpClientService.cs:line 43
   at HuedashConnectorsApp.WarehouseScheduleFunction.WarehouseDownload(Vendor vendor, IConfiguration configuration, IHttpClientService client, ILogger log) in C:\_Huedash\HuedashBackendGit\HuedashBackendCore\Huedash.ConnectorsApp\WarehouseScheduleFunction.cs:line 140

0 个答案:

没有答案