none
an existing connection was forcibly closed by the remote host RRS feed

  • Question

  • Hi All,

                 I have third party API and I'm consuming that API through my dot net C# Code.In locally I'm getting the response.But the same I'm getting the error 'existing connection was forcibly closed by the remote host' after publishing to IIS.

    I have gone through all the stackoverflow answers but no good luck. Please help me our to resolve this

    The steps I followed are,

     System.Net.ServicePointManager.Expect100Continue = false;
      ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

     in Web.config:

     <settings>
          <httpWebRequest useUnsafeHeaderParsing="true"/>
        </settings>
        <defaultProxy useDefaultCredentials="true"  enabled="false">
          <proxy bypassonlocal="False" proxyaddress="www.xyz.com" usesystemdefault="False"/>  
      </defaultProxy>

    The error as follows,

    An error occurred while making the HTTP request to https://www.xyz.com. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
    9136 22:58:10 ERROR The underlying connection was closed: An unexpected error occurred on a send.
    9136 22:58:10 ERROR Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
    9136 22:58:10 ERROR An existing connection was forcibly closed by the remote host


    Mani--MSDN

    Wednesday, December 20, 2017 7:10 AM

All replies

  • Hi Mani,

    >> I have third party API and I'm consuming that API through my dot net C# Code

    Could you share us the code which is used to consume API?

    >> But the same I'm getting the error 'existing connection was forcibly closed by the remote host' after publishing to IIS

    Did you publish to IIS in the same computer or different computers?

    If you go to Internet Options->Advanced->Use SSL 3.0, TLS 1.0,1.1,1.2, will these options be checked?

    What is the framework for your project? Did you install .net 4.5 and later, and target your project to .net 4.5 and later.

    Where did you get SecurityProtocol?

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 21, 2017 5:14 AM
  • Hi Tao Zhou,

                       Thanks for your reply. After the investigation I have come to know if I run the application through Visual studio on the same machine I'm getting the response.

                       but if I publish the same into IIS then I'm receiving the error.

                       Did you publish to IIS in the same computer or different computers?

                                -Same computer -its server

                         If you go to Internet Options->Advanced->Use SSL 3.0, TLS 1.0,1.1,1.2, will these options be checked?

                               -Yes Checked.

    What is the framework for your project? Did you install .net 4.5 and later, and target your project to .net 4.5 and later.

                                   .net 4.5


    Mani--MSDN

    Thursday, December 28, 2017 7:27 AM
  • Hi Mani,

    >> I have third party API and I'm consuming that API through my dot net C# Code

    What is the third party API? Is it WCF Soap Service or Rest Service? Is dot net C# Code asp.net?

    How did you consume the API?

    If you create a new wcf service, and consume it from dot net, will this issue exist after publishing the dot net to IIS?

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 29, 2017 2:23 AM