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

parth7676parth7676 USMember ✭✭

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

Answers

  • GeoffTanakaGeoffTanaka USMember

    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?

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

  • Ivan-LIvan-L USMember
    edited January 2017

    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.

  • VijayReddy.4607VijayReddy.4607 USUniversity

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

  • _lyra__lyra_ USMember

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

  • PeterKrastanovPeterKrastanov USUniversity
    edited May 2017

    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.

  • PeterKrastanovPeterKrastanov USUniversity

    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)

  • N_BauaN_Baua INMember ✭✭✭✭✭

    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

  • rafaelbparafaelbpa BRMember ✭✭

    I was facing the same problem today.

    Checking internet permission on droid project solved for me.

  • The same issue, Any solution?

  • MickyPaulMickyPaul Member
    edited May 2018

    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.

  • DesireGDesireG Member ✭✭

    I am getting the same issue when running tests on iOS

Sign In or Register to comment.