The underlying connection was closed: An unexpected error occurred on a send.

The underlying connection was closed: An unexpected error occurred on a send.

  

Hi

I encountered an error while calling a consumed soap webservice. Below is the error in the stack:

[1] The underlying connection was closed: An unexpected error occurred on a send.
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at ssTestWebservice.WRefPSA_PSQUERY_EXECUTE.WRefPSA_PSQUERY_EXECUTE.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at ssTestWebservice.WRefPSA_PSQUERY_EXECUTE.WRefPSA_PSQUERY_EXECUTE.QAS_EXECUTEQRYSYNC_OPER(WORCQAS_EXEQRY_SYNC_REQ_MSGTypeRecord inWSQAS_EXEQRY_SYNC_REQ_MSG, WORCQAS_GETQUERYRESULTS_RESP_MSGTypeRecord& outWSQAS_GETQUERYRESULTS_RESP_MSG)

[2] The handshake failed due to an unexpected packet format.
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   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.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   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.ConnectStream.WriteHeaders(Boolean async)


Appreciate if anyone can give me advice. Thanks!

Well,


The advice is, what does the other side tells you in their logging?

It could be a timeout on their side that causes it.



J. wrote:

Well,


The advice is, what does the other side tells you in their logging?

It could be a timeout on their side that causes it.



There's nothing on the other's side's logging. I guess it means that the connection was not even successful in the first place to even hit their logs.


Hi Michael

It looks SSL/TLS issue while calling the webservice. Check what is the authentication you are using to connect to web service.

Iit looks like your server requires an SSL-wrapped connection.

Also this  error indicates that you are trying to access another server using SSL while the another server is only supporting non-SSL connection. Usually, this means that port 143 was specified, and the Use a secure connection (SSL) option was enabled.