System.IO.IOException:无法将数据写入传输连接:现有连接被远程主机强制关闭

问题描述 投票:0回答:2

我一直在尝试使用 SSLstream 连接到服务器。 我有连接证书并且所有信用都是正确的。但不知怎的,它得到如下错误:

System.IO.IOException: Unable to write data to 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.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
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.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
at SslTcpClient.Open() in d:\Ishit\Fix\Webservice development - XML communication protocol\Work-by-Developer\ishit\EPP_Webservice\App_Code\SslTcpClient.cs:line 102
at EPP_Transaction_Webservice.Hello() in d:\Ishit\Fix\Webservice development - XML communication protocol\Work-by-Developer\ishit\EPP_Webservice\App_Code\EPP_Transaction_Webservice.cs:line 62

请帮我解决这个错误。 预先感谢。

c# asp.net .net ssl-certificate
2个回答
0
投票

我认为您可能需要检查您尝试连接的服务器是否已将您的 IP 列入黑名单/阻止。这看起来像是阻塞/拒绝通信的东西。当我的 sftp 服务器阻止我运行客户端的 IP 时,我遇到了类似的错误。 华泰 美联储


0
投票
  1. 检查连接加密类型:SSL3? TLS10? TLS11? TLS12? 为此,可以使用 Firefox > 页面信息 > 安全选项卡 > 技术详细信息
  2. 添加以下行应用程序加载

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 |安全协议类型.Tls12;

System.Net.ServicePointManager.SecurityProtocol = 默认值:System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls;

注意:Tls11/Tls12 请求 .net >= v4.5 ??

© www.soinside.com 2019 - 2024. All rights reserved.