Ideas & Feature Requests

Share your ideas on how Test Cloud can better help you deliver higher quality apps faster.

Add retries in Xamarin UITest Android Setup() to handle "System.Net.Sockets.SocketException : The socket has been shut down"

See the thread here: https://forums.xamarin.com/discussion/99858/xamarin-uitest-error-setup-an-error-occurred-while-sending-the-request-android

Every once in a while, I get the following error while running Xamarin UITests locally on an Android emulator -

Errors and Failures:
1) SetUp Error : MYCOMPANY.MYPROJECT.Tests.Integration.Acceptance.Features.MYSCENARIO(Android).MYTEST
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request
----> System.IO.IOException : Error writing request

Tests will be working fine for multiple test runs when randomly this happens. We typically stop what we are doing, close and restart the Android Emulator on the build server, and a build re-queue fixes it... until the next time it happens.

I saw this thread https://forums.xamarin.com/discussion/24398/vs2013-with-xamarin-uitest-issues-getting-a-test-for-a-simple-anrdoid-app-to-run-repl? from back in 2014, but it looks like the issue is still happening.

Could the team working on Xamarin UITest add some retries in 'Setup()'?

Here's a sample exception and stack trace -

Errors and Failures:
1) SetUp Error : MYCOMPANY.MYPROJECT.Tests.Integration.Acceptance.Features.MYSCENARIO(Android).MYTEST
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request
----> System.IO.IOException : Error writing request
----> System.Net.Sockets.SocketException : The socket has been shut down
at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x0045a] in <68ba4a0a54764b819b8b058de1b791f4>:0
--- End of stack trace from previous location where exception was thrown ---
at Xamarin.UITest.Shared.Http.HttpClient.SendData (System.String endpoint, System.String method, System.Net.Http.HttpContent content, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable`1[T] timeOut) [0x000ea] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.String arguments, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable`1[T] timeOut) [0x00017] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Shared.Http.HttpClient.PostUntilExpectedResultReceived (System.String endpoint, System.String arguments, System.String expectedContent, System.Int32 retries) [0x000d2] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Shared.Android.HttpApplicationStarter.Execute (System.String intentJson) [0x00000] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.LaunchApp (System.String appPackageName, Xamarin.UITest.Shared.Android.ApkFile testServerApkFile, System.Int32 testServerPort) [0x000a4] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.LaunchApp (Xamarin.UITest.Shared.Android.ApkFile appApkFile, Xamarin.UITest.Shared.Android.ApkFile testServerApkFile, System.Int32 testServerPort) [0x00007] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration, Xamarin.UITest.Shared.Execution.IExecutor executor) [0x001c1] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration) [0x00000] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <b2dbb1bd4b224d63be0561fef2070e3b>:0
at MYCOMPANY.MYPROJECT.Tests.Integration.AppInitializer.StartApp (Xamarin.UITest.Platform platform) [0x00019] in <05016406ea704e18b30dec9fe44865d6>:0
at MYCOMPANY.MYPROJECT.Tests.Integration.Acceptance.Features.FeatureBase.BeforeEachTest () [0x00000] in <05016406ea704e18b30dec9fe44865d6>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
--IOException
at System.Net.WebConnectionStream.EndWrite (System.IAsyncResult r) [0x000b8] in <5afdc70d980c4033b3878286f754d091>:0
at System.IO.Stream+<>c.<BeginEndWriteAsync>b__53_1 (System.IO.Stream stream, System.IAsyncResult asyncResult) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at (wrapper delegate-invoke) System.Func`3[System.IO.Stream,System.IAsyncResult,System.Threading.Tasks.VoidTaskResult]:invoke_TResult_T1_T2 (System.IO.Stream,System.IAsyncResult)
at System.Threading.Tasks.TaskFactory`1+FromAsyncTrimPromise`1[TResult,TInstance].Complete (TInstance thisRef, System.Func`3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x0031d] in <68ba4a0a54764b819b8b058de1b791f4>:0
--SocketException
at System.Net.WebConnection.EndWrite (System.Net.HttpWebRequest request, System.Boolean throwOnError, System.IAsyncResult result) [0x00099] in <5afdc70d980c4033b3878286f754d091>:0
at System.Net.WebConnectionStream.WriteAsyncCB (System.IAsyncResult r) [0x00013] in <5afdc70d980c4033b3878286f754d091>:0

 

  • Emmanuel Huna
  • Aug 23 2017
Device Manufacturer Nokia
Device Model Name Android Emulator
Operating System Version V7
  • Attach files