Only 2 requests are working with ASMX client
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 576
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 2
Description
I've generated an ASMX service client in Visual Studio, then in a loop I'm creating the new client instance, calling the method and closing the client. On 3 try I'm getting error:
`A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond`.
I've reproduced the issue with .NET6, .NET8. I've tried the same with .NET Framework 4.7.2 but it's working fine without any errors. If I'll add about 5 sec delay between the requests it seems to be working fine
I can't provide access to third-party ASMX service, but how can I trace the root of the issue?
Microsoft.Tools.ServiceModel.Svcutil 2.1.0
The code is pretty simple:
```
var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.AllowCookies = true;
binding.MaxBufferSize = int.MaxValue;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
for (int i = 0; i < 10; i++)
{
using (var svc = new ServiceSoapClient(binding, new EndpointAddress(new Uri(url))))
{
svc.ClientCredentials.UserName.UserName = login;
svc.ClientCredentials.UserName.Password = password;
// call methods
}
}
```
StackTraces:
```
in System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
in System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
in System.Net.Sockets.Socket.<g__WaitForConnectWithCancellation|285_0>d.MoveNext()
in System.Net.Http.HttpConnectionPool.d__104.MoveNext()
```
```
in System.Net.Http.HttpConnectionPool.d__104.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.HttpConnectionPool.d__103.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.HttpConnectionPool.d__105.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.HttpConnectionPool.d__79.MoveNext()
in System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.d__1.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.d__6.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.HttpConnectionPool.d__89.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.AuthenticationHelper.d__17.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.RedirectHandler.d__4.MoveNext()
in System.Threading.Tasks.ValueTask`1.get_Result()
in System.Net.Http.DecompressionHandler.d__16.MoveNext()
in System.Net.Http.HttpClient.<g__Core|83_0>d.MoveNext()
in System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.d__13.MoveNext()
```
```
in System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(HttpRequestException requestException, HttpRequestMessage request, HttpAbortReason abortReason)
in System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.d__13.MoveNext()
in System.ServiceModel.Channels.RequestChannel.d__33.MoveNext()
in System.ServiceModel.Channels.RequestChannel.d__32.MoveNext()
in System.Runtime.TaskHelpers.WaitForCompletionNoSpin[TResult](Task`1 task)
in System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
in System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
in System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
in System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall methodCall, ProxyOperationRuntime operation)
in System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetMethod, Object[] args)
in generatedProxy_1.GetData(GetDataRequest )
```
Contributor guide
Assessment
This issue has not been assessed yet.