1

I have been trying to connect to the server using SSLstream. I have certificate for the connection & all the creds are correct. But somehow it gets the error as below:

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

Please help me to solve this error. Thanks in advance.

yasmuru
  • 1,178
  • 2
  • 20
  • 42
user3335575
  • 11
  • 1
  • 2

2 Answers2

0

I think you might have to check if the server you are trying to connect to is black-listing/blocking your IP. This looks like something blocking/rejecting the communication. I had a similar error when my sftp server was blocking the IP I was running the client from. HTH Fed

Fed X
  • 11
  • 1
  • 2
0
  1. Check Connection Encrypted type: SSL3? TLS10? TLS11? TLS12? for this may be use firefox > page Info > Security Tab > Technical Details
  2. add bellow line app load

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

or

System.Net.ServicePointManager.SecurityProtocol = default:System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls;

note: Tls11/Tls12 request .net >= v4.5 ??