Help!A connection attempt failed because the connected party did not properly respond

Discussion in 'ASP.NET 2.0' started by nlaweb, Oct 15, 2009.

  1. :confused:
    This website was working for ages until recently though I have myself not made any changes.
    The website is hosted with Fasthosts and it's domain is registered with 123-reg.

    Whenever I try and talk to a webservice it now throws the below error message back. I've contacted Fasthosts and they think I've changed the code because they think it's wrong and 123-reg have no idea.
    The webservice is used on other websites I have and they are working fine, it's only this one.

    Help!:(

    Code:
    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 81.31.115.21:443
    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: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 81.31.115.21:443
    
    Source Error: 
    
    Line 198:        ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
    Line 199:
    Line 200:        System.Net.HttpWebResponse wr = (System.Net.HttpWebResponse)wreq.GetResponse();
    Line 201:        //read xml stream
    Line 202:        if (wr.StatusCode == System.Net.HttpStatusCode.OK)
    
    Source File: e:\DOMAINS\m\mynlalandlord.org.uk\user\htdocs\test1.aspx.cs    Line: 200 
    
    Stack Trace: 
    
    [SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 81.31.115.21:443]
       System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
       System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
       System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224
    
    [WebException: Unable to connect to the remote server]
       System.Net.HttpWebRequest.GetResponse() +5314029
       Default2.getSSL(String MemNo) in e:\DOMAINS\m\mynlalandlord.org.uk\user\htdocs\test1.aspx.cs:200
       Default2.btnValidate(Object sender, EventArgs e) in e:\DOMAINS\m\mynlalandlord.org.uk\user\htdocs\test1.aspx.cs:52
       System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118
       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    
    This is the class that the code errors on:

    Code:
    public static XmlDocument getSSL(string MemNo)
        {
            //retrieve XML document from Rest server for Stratum details
            string url;
            url = "https://81.31.115.21/";
            string result = "Error communicating with server";
            XmlDocument xmlDoc = new System.Xml.XmlDocument();
    
            //allows for validation of SSL certificates 
            [COLOR="DarkOrange"][B]System.Net.HttpWebRequest wreq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);[/B][/COLOR]
            wreq.Proxy = null;
            wreq.Credentials = CredentialCache.DefaultCredentials;
            wreq.Method = "GET";
            //wreq.Timeout = 10000;
    
            //ignore all certificate errors
            ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
    
            System.Net.HttpWebResponse wr = (System.Net.HttpWebResponse)wreq.GetResponse();
            //read xml stream
            if (wr.StatusCode == System.Net.HttpStatusCode.OK)
            {
                System.IO.Stream s = wr.GetResponseStream();
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
                System.IO.StreamReader readStream = new System.IO.StreamReader(s, enc);
                result = readStream.ReadToEnd();
                xmlDoc.LoadXml(result);
                readStream.Close();
            }
            wr.Close();
            return xmlDoc;
        }
    
     
  2. Bruce

    Bruce DiscountASP.NET Staff

Share This Page