I have a problem with my .net Client for communicating with a SOAP/REST interface:
with .net fw 4.8 (original implementation) I get intermittent connection errors:
2022-09-12 14:33:44,941 [1] ERROR _Test_Client.Random Test - Die zugrunde liegende Verbindung wurde geschlossen: Die Verbindung wurde unerwartet getrennt..
2022-09-12 14:33:44,952 [1] ERROR _Test_Client.Random Test -
Server stack trace:
bei System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
bei System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
bei System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
bei _Test_Client. ServiceReference.IService.A(ARequest request)
bei Test_Client. ServiceReference. ServiceClient.Test_Client.ServiceReference.IService.A(geABCRequest request) in C:\Users\A\source\repos\Test-Client\Connected Services\ ServiceReference\Reference.cs:Zeile 721.
bei Test_Client. ServiceReference.ServiceClient.getABC() in C:\Users\ A\source\repos\Test-Client\Connected Services\ServiceReference\Reference.cs:Zeile 726.
bei Test_Client.Random Test.randomRequest() in C:\Users\A\source\repos\Test-Client\RandomTest.cs:Zeile 69.
These errors are load-dependent (more with more load), but otherwise seem completely random. In a short analysis with Wireshark on Client side I saw TCP out of order warnings.
I also get keepalive errors (The underlying connection was closed: A connection that was expected to be kept alive was closed by the server) intermittently.
The problem (either error code) does not occur with keepalive=false. Retries mitigate the problem, but I would like to avoid it altogether.
I tried other Client Frameworks to test against this problem: I tried .net 6.0 and could not reproduce the errors. After reading the releasenotes of the .net (core) FW, I assumed the changes in HTTPClient connection handling after 2.1 may be the cause - a socketshttpClientHandler was added.
In my client with .net (core) 3.1 I tested with the socketshttpClientHandler on and off, but still could not reproduce the error.
Is there something I'm missing? I am now wondering whether there is a bug in .net FW that is not present in .net (core).
I am looking forward to your insightful answers