locked
WebException thrown on one machine

    Question

  • Hi all,

    I have recently updated my app to a Universal Windows App. My app makes web requests (HttpWebRequest) to get data from my server. This works fine on all machines I have tried, but one user reports that he is not seeing the data. Traces in the app indicates that HttpWebRequest.EndGetResponse() throws a WebException with the message "Unable to connect to the remote server".

    The data that the app tries to receive is a simple text file on a web server and we have verified that his computer can access the file through a web browser. So why can the app not access the file? How can I get more information about this error?

    Remember that I only have one user reporting this issue. Debugging is a real pain because I can not add additional debug information to the app without submitting it to the store. 

    All help will be appreciated,
    Jimmi

    Monday, June 16, 2014 8:58 PM

Answers

All replies

  • Where is that file "hosted"? Is it hosted on a Private IP, if so does your manifest file have the appropriate capabilities?

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, June 17, 2014 12:47 AM
    Moderator
  • is that specific user using a authenticated proxy server and how your code looks to make calls?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, June 17, 2014 9:25 AM
  • The files are not hosted on a private ip. They are located on my website hosted by one.com.

    I do not know if the user uses an authenticated proxy server. My guess would be no since this is a private computer. Also note that the file loads fine in internet explorer.

    The relevant part of my code is pasted below. The exception is as mentioned thrown by the call to httpWebRequest.EndGetResponse(asyncResult)

    HttpWebRequest httpWebRequest = (HttpWebRequest)System.Net.WebRequest.Create(requestToExecute.Request.GetUrl() + "?unique=" + DateTime.Now.Ticks);
    httpWebRequest.Method = "GET";
    httpWebRequest.BeginGetResponse(new AsyncCallback(ResponseReady), httpWebRequest);
    
    async private static void ResponseReady(IAsyncResult asyncResult)
    {
      try
      {
        HttpWebRequest httpWebRequest = (HttpWebRequest)asyncResult.AsyncState;
        HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.EndGetResponse(asyncResult);
    
        Stream responseStream = httpWebResponse.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream);
    
        ...
      }
      catch (Exception e)
      {
        //request failed. Lets just ontinue with no result
        requestInfo.Request.RequestSuccess = false;
        requestInfo.Request.ErrorMessage = e.GetType() + " : " + e.Message;
      }
    }
    


    Wednesday, June 18, 2014 7:28 PM
  • The best way to troubleshoot System.Net issues on Windows is to collect a System.Net trace. The steps to collect a System.Net trace are documented here: http://blogs.msdn.com/b/jpsanders/archive/2011/12/16/how-to-take-a-system-net-trace-from-metro-style-applications-developer-preview.aspx

    Once you collect the trace of the repro, you can either investigate it yourself or share it through OneDrive/ Dropbox if you want me to analyze it for you.


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    • Marked as answer by JimmiChr Sunday, July 13, 2014 10:38 PM
    Thursday, June 19, 2014 10:39 PM
    Moderator