Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

azure

I am trying to run/debug locally my cloud project, but service bus connection keeps crashing with error:

<15:46:59> MessagingFactory successfully created
<15:47:39> Exception: The underlying connection was closed: An unexpected error occurred on a send.. 

....
   System.IO.IOException: Unable to read data from the transport connection: 
    An existing   connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)}

Also I receive this error when using Service Bus Explorer tool.

When deploy to cloud everything works ok, service bus connection is ok.

Can anyone help me with this? what could be the reason? Thank you in advance!

like image 250
oanaioana Avatar asked May 07 '14 06:05

oanaioana


2 Answers

Maybe the problem is with the SSL certificate validation protocol. Try this to force the latest protocol type.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
like image 163
Koen van der Linden Avatar answered Sep 28 '22 19:09

Koen van der Linden


There are several reason leading to such error so you may check the following

  • You have configured the settings correctly.
  • Firewall in your system allows the connection (protocol, host & port)
  • DNS servers configured in your network are able to resolve the host.
  • Your ISP is not blocking your connection due to any reason

Since there is no fixed solution for your error, you may have to work a little hard to figure out the actual issue. You may also find some useful information from the log files if enabled.

like image 27
pushpraj Avatar answered Sep 28 '22 18:09

pushpraj