底层连接已关闭:发送时发生意外错误

本文关键字:意外 错误 连接 | 更新日期: 2023-09-27 18:02:17

我试图在本地运行/调试我的云项目,但服务总线连接不断崩溃错误:

<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)}

当我使用服务总线资源管理器工具时,我也收到这个错误。

当部署到云端时,一切正常,服务总线连接正常。

有谁能帮我一下吗?原因是什么呢?提前感谢!

底层连接已关闭:发送时发生意外错误

问题可能出在SSL证书验证协议上。尝试强制使用最新的协议类型。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

有几个原因导致这样的错误,所以你可以检查以下

  • 您已经正确地配置了设置。
  • 您系统中的防火墙允许连接(协议,主机&端口)
  • 您的网络中配置的DNS服务器能够解析主机。
  • 您的ISP没有因为任何原因阻止您的连接

由于你的错误没有固定的解决方案,你可能不得不努力找出实际的问题。如果启用了,您还可以从日志文件中找到一些有用的信息。