我们在高级计划上托管了 Azure 功能,并且在调用 On Premise API 时间歇性地收到System.Net.Sockets.SocketException并显示以下错误消息 -
发送请求时出错。无法从传输连接读取数据:现有连接被远程主机强行关闭。现有连接被远程主机强行关闭。
功能在 .net core 3.1 中,我们使用 httpclientfactory 来获取 httpclient... 我们没有设置超时值,所以默认应该是 100 秒。根据网络捕获,我们看到连接在 120 秒后超时。
这也发生在 .NET core 3.1 中的 Azure App Services(.net core Web API)中,并且使用与 httpclient 相同的方式。
using (var httpClient = this.httpClientFactory.CreateClient())
请让我知道是否有人有可能导致的想法。我们已经验证,当从其他 On Premise API 调用 On Premise API 并且没有看到任何错误时,它们可以正常工作。我不认为这将是 httpclient 端的问题,而不是 Azure 服务 / On Premise API 之间的网络问题,但我可能错了,所以想和你们核实一下。
下面是堆栈跟踪 -
System.Net.Http.HttpRequestException:在 System.Net.Http.HttpConnection+d__53.MoveNext(System.Net.Http,版本=4.2.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a)在 System.Runtime.ExceptionServices.ExceptionDispatchInfo。在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess 抛出(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken =7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, 版本=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib ,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices。配置任务等待1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.HttpConnectionPool+<SendWithNtConnectionAuthAsync>d__48.MoveNext (System.Net.Http, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Http.HttpConnectionPool+d__47.MoveNext (System.Net.Http, Version=4.2.2.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken= 7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, 版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.RedirectHandler+<SendAsync>d__4.MoveNext (System.Net.Http, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Http.DiagnosticsHandler+d__2.MoveNext (System.Net.Http, Version=4.2.2.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Net.Http.HttpConnection+d__53.MoveNext 处理的内部异常 System.IO.IOException:在 System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException (System.Net.Sockets, 版本=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.GetResult (System.Net.Sockets, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Threading .Tasks.ValueTask1.get_Result (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable
1+ConfiguredValueTaskAwaiter.GetResult (System.Private.CoreLib, 版本=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Security.SslStream+<g__InternalFillBufferAsync|215_0>d 1.MoveNext (System.Net.Security, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Threading.Tasks.ValueTask
1.get_Result (System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1+ConfiguredValueTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Security.SslStream+<ReadAsyncInternal>d__214
1.MoveNext(System.Net.Security,版本=4.1.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a)在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,Culture=neutral , PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.PrivateNonSuccessAndDebuggerNotification .CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在系统.Threading.Tasks.ValueTask1.get_Result (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable
1+ConfiguredValueTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Http.HttpConnection+d__87.MoveNext (System.Net.Http, Version=4.2.2.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken= 7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, 版本=4.0.0.0,Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Http.HttpConnection+ d__84.MoveNext(System.Net.Http,版本=4.2.2.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a)在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.PrivateNonSuccessAndDebuggerNotification .CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Threading.Tasks.ValueTask1.get_Result (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable
1+ConfiguredValueTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) 在 System.Net.Http.HttpConnection+d__53.MoveNext (System.Net.Http, Version=4.2.2.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) 在 System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException 处理的内部异常 System.Net.Sockets.SocketException: