HttpRequestException: workaround, solution, or open feature request for this exception? RRS feed

  • Question

  • User263424 posted

    When I run our test suite locally using a physical device I often see this exception when running Android tests.

        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.

    This causes the test to fail before it's able to perform the first action. What's strange is when I run the entire suite a few tests might fail with this exception, but the prior or following test will pass with no issues, then this exception won't resurface for a few more tests. This is especially frustrating when some test fixtures are set up to test data or settings persisting between tests in the same fixture.

    We have our build servers set up to run UI tests incrementally (nightly and per pull request via GitHub integration) and it's frustrating to see failed tests that have nothing to do with the performance of our app or test scripts.

    My question:

    Does anyone have a workaround for this issue, or a feature request that's seeing some attention? The closest related issue I've seen on the forums is from Emmanuel Huna with a corresponding feature request as well, but it hasn't seen much attention since he posted it.

    Device specific information:

    This issue occurs on my Windows vm (Windows 10 & VS 2017) and my primary Mac install (Sierra & VS for Mac)

    Doesn't seem to be device specific as it happens on Emulators and physical devices (Android 5, 6, 7) on a variety of make and model phones.

    Thursday, October 12, 2017 8:01 PM

All replies

  • User279986 posted

    Just clarifying is this when the UI Test sends the instructions to the device or when the device attempts to send a network request?

    If you are using network calls is it possible to use a fake/mock service. UI Tests generally shouldn't require network calls as then that's more of an integration test. Quite alot of work but then the tests would be far more reliable and faster since you don't have to wait for response.

    Thursday, October 12, 2017 8:40 PM
  • User263424 posted

    Hey Lewis, thanks for replying. This is when I'm running the UI tests so the UI test is sending instructions to the device. More often than not, I can retry the same test on the same device directly after this exception is thrown and the UI test will send the instructions with no issues. I can post the whole stacktrace if you think that would help :smile:

    Thursday, October 12, 2017 10:47 PM
  • User279986 posted

    Are you running the latest UITest packages etc? If android make sure you have the internet permission and check monitor/logcat for errors.

    Sunday, October 15, 2017 8:00 PM
  • User263424 posted

    We're currently running 2.1.3, but this error has occurred on every version of Xamarin UI test we've used thus far. We have internet permissions enabled, but I'll try to find some other errors to bring to this thread.

    Monday, October 16, 2017 2:46 PM
  • User263424 posted

    I've confirmed this issue also occurs on Xamarin.UITest 2.1.4. Does anyone else have any ideas on how to fix this?

    Wednesday, October 25, 2017 3:17 PM
  • User306807 posted

    I had the same problem, my current solution is using Xamarin.UITest 1.3.8, this NuGet package works fine!

    Tuesday, January 23, 2018 5:22 PM
  • User327734 posted

    We have this problem too and have had it since we started using ui test, we're using uitest 2.2.2 I was in contact with support about it but the trail went dead

    Thursday, January 25, 2018 11:16 AM