我一直在尝试使用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
请帮我解决这个错误。 提前谢谢。
答案 0 :(得分:0)
我认为您可能需要检查您尝试连接的服务器是否为黑名单/阻止您的IP。这看起来像阻止/拒绝通信的东西。当我的sftp服务器阻止我正在运行客户端的IP时,我遇到了类似的错误。 HTH 馈
答案 1 :(得分:0)
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
或
System.Net.ServicePointManager.SecurityProtocol = default:System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls;
注意:Tls11 / Tls12请求.net> = v4.5 ??