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

  • Question

  • I have a c# web application that calls an API, It was working fine until past two weeks since then it started failing with below error.
    An existing connection was forcibly closed by the remote host

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
    When i try the same code with c# console application it is working fine without any errors.
    Below is my sample code:
    string username = "";
                    string password = "";
                    string INum = "";
                    string url = "https://test.com?UserName=" + username + "&Password=" + password + "&inumber=" + INum;
                    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse response1 = (HttpWebResponse)objRequest.GetResponse();
                    XmlDocument xDoc = new XmlDocument();
                    XmlTextReader myXMLReader = null;
                    myXMLReader = new XmlTextReader(response1.GetResponseStream());
                    xDoc.Load(myXMLReader);
                    
                    String Message, PNRef, result, status;
                    if (xDoc.ChildNodes.Item(0).ChildNodes[0].Name == "Message")
                    {
                        Message = xDoc.ChildNodes.Item(0).ChildNodes[0].InnerText;
                        
                    }
                    if (xDoc.ChildNodes.Item(0).ChildNodes[1].Name == "Pf")
                    {
                        Pf = xDoc.ChildNodes.Item(0).ChildNodes[1].InnerText;
                        
                    }
                    
    Can anyone please let me know why am i getting the error?
    Wednesday, November 30, 2016 5:29 PM

All replies

  • Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Can anyone please let me know why am i getting the error?

    So where is the stack trace and the inner.exception message? Houdini is not in the forum today.

    Wednesday, November 30, 2016 7:12 PM
  • Hi vinisha,

    Did you use the same sample code in web application? How did you develop this API? Is it WCF, WEB API or asmx web service? Are you able to check whether there is any exception in API side?

    Are you able to use Fiddler to capture the request and response for API?

    Best Regards,

    Edward


    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 1, 2016 2:06 AM