0

We are developing a .Net application (compiled for .net 4.0) that communicates to a soap web service.

The application has been working fine on several machines when retreiving the http web response content. However on one of the machines (Windows Server 2008 R2) the application is not able to retreive the response. This is a code example:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://200.57.3.82:3443/AdministradorQr/WebServiceDodaPort?wsdl");
request.Method = "GET";
WebResponse response;
Stream responseStream = response.GetResponseStream();
string result = string.Empty;
using (StreamReader streamReader = new StreamReader(responseStream))
{
   result = streamReader.ReadToEnd();
}

The exception we get is:

The underlying connection was closed: An unexpected error occurred on a send. System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.TlsStream.CallProcessAuthentication(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()

The thing is that using the same code with a different URL we get a sucessfull response, and the problem is only happening in one machine even though there is another machinge also using Windows 2008 that works just fine.

Currently we cannot upgrade .net framework to try using solutions like use of TLS 1.2 found in some places like this one: "The underlying connection was closed: An unexpected error occurred on a send." With SSL Certificate

As I mentioned, it is very strange that the same code works just fine in other machines using the same Windows/.net version and it is also strange that for other URLs like http://www.yahoo.com works fine

  • do you have any antivirus software installed on this machine? can you try after disabling it? – Ashif Nataliya Feb 02 '18 at 22:28
  • We have McAfee installed... we disabled real time protection and tested but we still get the same exception – Javier Galindo Feb 02 '18 at 22:35
  • We also tried the solution for .net framework 4.0 to use ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; However, if we use it we get an error saying the the specified protocol is not supported – Javier Galindo Feb 02 '18 at 22:36

1 Answers1

1

Not sure if it can help you but you can try adding below line in "Global.asax -> Application_Start" function. See it it works. Basically this code will force your application to use TLS1.2 only and you do not need to upgrade your framework.

"System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;"

Shashank
  • 91
  • 1
  • 4