locked
The underlying connection was closed on windows 8.1 but not on windows phone in unversal app

    Question

  • Hello,

    we started developing a universal app targeting Windows phone 8.1 and Windows 8.1. In the solution we added a portable class library targeting both (Windows 8.1 and Windows Phone 8.1) and containing the whole logic for contacting the webservice.

    We then started developing the Windows Phone Version of the app and everything works fine. When we started developing for Windows 8.1 store app we often get the when calling the webservice.

    The exception is raised at:

    var erg = (HttpWebResponse)_request.EndGetResponse(asyncResult);

    On Windows phone we never get that exception and interestingly it sometimes works on the tablet but more often it does not.

    Does anybody has an idea where to search for that Problem?

    Thank you very much,

    Tobsel

    Friday, May 09, 2014 6:20 PM

Answers

  • I rewrote the whole WebService logic with HttpClient and now it works without any problem on WP 8.1 and Windows 8.1. It seems that the property:

    handler.PreAuthenticate = true;

    made the difference.

    Don`t ask me why?

    • Marked as answer by Tobsel Thursday, May 15, 2014 8:52 PM
    Thursday, May 15, 2014 8:51 PM

All replies

  • Collect and share a System.Net trace by following the steps 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

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

    Friday, May 09, 2014 7:05 PM
    Moderator
  • Hello,

    I changed my machine.config file like shown in the link you posted and with the changed machine.config file it works. I am not able to reproduce the error when the changed file is active. I just added the <system.diagnostics> section like it is described in your link.

    If I make the saved Maschine.config file activ again it is not working anymore.

    One more to say. It seems that the first access to the webservice always works, but the others only sometimes.

    Thank you very much,

    Tobsel

    Friday, May 09, 2014 8:37 PM
  • You can probably collect a Network trace by using a tool called Network Monitor or Wireshark and then analyze the trace by looking for TCP-RST packets.

    If the URL is public, please share the HTTP request details so that I can try and repro the issue myself.


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

    Friday, May 09, 2014 8:42 PM
    Moderator
  • Hi,

    the URL is not public, so I cannot share the Details of the request with you. I installed Network Monitor. Now where exactly shall I look for the problem. On the Windows phone side where everything works I have less entries when using the webservice.

    On the Windows 8.1 side I can find many

    "TCP:[ReTransmit #33]" entries and one

    HTTP:Response, HTTP/1.1, Status: Unauthorized, URL: /orawsv , Using Basic realm="XDB" Authentication entry which both are not there on the WP 8.1 side.

    Thank you very much,

    Tobsel

    Saturday, May 10, 2014 11:18 AM
  • The TCP Retransmit of the "payload" is fine, as long as it gets eventually accepted. The 401 Unauthorized error with a Basic HTTP Header means that your web service is expecting authentication. Does the Phone provide any credentials, but the Windows app does not?

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

    Monday, May 12, 2014 10:58 PM
    Moderator
  • No, the phone does not provice anything else. Allo logic of the webservice is in the portable class library. The ViewModels and other logic is in the ".shared". The Windows 8.1 does only contain the page xaml. I have no idea at the moment and I do not understand why it works some times and sometimes not and on WP 8.1 it works always.
    Tuesday, May 13, 2014 5:55 PM
  • I rewrote the whole WebService logic with HttpClient and now it works without any problem on WP 8.1 and Windows 8.1. It seems that the property:

    handler.PreAuthenticate = true;

    made the difference.

    Don`t ask me why?

    • Marked as answer by Tobsel Thursday, May 15, 2014 8:52 PM
    Thursday, May 15, 2014 8:51 PM