locked
System.Net.Http.HttpRequestException exception will running the UI Test on Physical Device.. RRS feed

  • Question

  • User207894 posted

    I have created a simple Xamarin.Forms(Portable) project and included UI Test project in it. But when i am trying to run the test in physical device it giving me below mentioned exception.

    Test Name:  AppLaunches
    Test Outcome:   Failed
    Result Message: 
    SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
      ----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
    Result StandardOutput:  Full log file: C:\Users\Admin\AppData\Local\Temp\uitest\log-2016-10-22_11-04-53-698.txt
    Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
    Android test running Xamarin.UITest version: 2.0.0.1534
    Initializing Android app on device ZX1D63GCCL with installed app: co.veloxcore.UITestSample2
    Signing apk with Xamarin keystore.
    Skipping installation: Already installed.
    

    Here is the link to my project: XamarinUITest

    Saturday, October 22, 2016 5:43 AM

All replies

  • User171855 posted

    I'm getting this error as well, while testing an Android app on a physical device. I found that it works the first time, but then fails until I reinstall the app. Did you ever find anything out about this issue?

    Wednesday, October 26, 2016 7:05 PM
  • User230062 posted

    I am getting the same error as well. Anything about this issue?

    Wednesday, December 14, 2016 4:46 AM
  • User281904 posted

    I am also getting the same issue. The first query of the UI Test works but then the following error is logged:

    Exception: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) at Xamarin.UITest.Shared.Http.HttpClient.Post(String endpoint, String arguments, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) at Xamarin.UITest.Android.AndroidGestures.Query[T](ITokenContainer query, Object[] args, String methodName) at Xamarin.UITest.Android.AndroidGestures.Query(AppQuery query) at Xamarin.UITest.Android.AndroidApp.<Query>c__AnonStorey0.<>m__0() at Xamarin.UITest.Utils.ErrorReporting.With[T](Func`1 func, Object[] args, String memberName)

    I cannot figure out how to get past this.

    Wednesday, January 4, 2017 1:23 PM
  • User129959 posted

    Hi, Even I am facing the same issue, any update on this? I am using Xamarin.UI Test V 2.0.7

    Monday, March 20, 2017 9:32 AM
  • User316318 posted

    Happen to me. First time working if fresh install but after that it is not working. Any solution?

    Friday, April 28, 2017 3:34 PM
  • User224712 posted

    I have the same issue at the moment not sure what triggered it but I can't run anything not the first time not at all. Now when I tried using Resharpers unit testing tool it only worked the first time and then died.

    I tried the Rider the new IDE and it works there for some reason but it seems rather stupid to use an IDE still in development just to run my tests, I have no idea what in Visual Studio is causing this but I am using VS 2015 and I tried VS 2017 and in both I get the exception.

    Monday, May 8, 2017 8:33 AM
  • User224712 posted

    And this is what I got this Morning

    Execution failed with exception: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:64752 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at Xamarin.UITest.Shared.Http.HttpClient.Request(String method, String endpoint, ExceptionPolicy exceptionPolicy, Nullable1 timeOut) at Xamarin.UITest.Android.AndroidGestures.Dump() at Xamarin.UITest.Utils.TreePrintHelper.PrintTree(ITreePrinter treePrinter) at Xamarin.UITest.Queries.AppPrintHelper.Tree(Nullable1 console) at Mono.CSharp.Evaluator.Evaluate(String input, Object& result, Boolean& result_set) at Xamarin.UITest.Repl.Evaluation.MonoCSharpReplEngine.Evaluate(String line) at Xamarin.UITest.Repl.PromptHandler.PrintTree() at Xamarin.UITest.Repl.PromptHandler.HandleInput(ConsoleKeyInfo key) at Xamarin.UITest.Repl.Program.Main(String[] args)

    Tuesday, May 9, 2017 8:08 AM
  • User318788 posted

    In most cases, This error appears when HttpClient can not evaluate the domain based (and sub-domain so) URLs OR localhost URLs, May be you can try accessing with IP address instead.

    Hope this helps.

    Regards, N Baua

    Thursday, June 22, 2017 12:26 PM
  • User304647 posted

    I was facing the same problem today.

    Checking internet permission on droid project solved for me.

    Thursday, September 7, 2017 6:32 PM
  • User201467 posted

    The same issue, Any solution?

    Monday, January 15, 2018 9:51 PM
  • User368453 posted

    I am having same issue in my both Shared and .NETStandard project even after checking internet and networkstate on android project. Please reply if there is any solution for it.

    Friday, May 11, 2018 5:49 AM
  • User366673 posted

    I am getting the same issue when running tests on iOS

    Monday, January 14, 2019 4:29 PM
  • User391008 posted

    I'm having this issue on an Xamarin.Forms Android project, I have the internet permission set

    Monday, May 25, 2020 11:11 PM
  • User391008 posted

    I've raised an issue here: https://github.com/xamarin/xamarin-android/issues/4721 As there seems to be no solution

    Monday, May 25, 2020 11:29 PM