"POST failed" error when executing tests via Jenkins

I am getting major instabilities (1 out of every 9 to 10 tests has this problem) when executing my tests over Jenkins (which uses SSH to connect to the Mac).

Error while performing Tap(Marked("selector")) Exception: System.Net.WebException: POST Failed at Xamarin.UITest.Shared.Http.HttpClient.HandleHttpError (System.String method, System.Exception exception, ExceptionPolicy exceptionPolicy) <0x6be4788 + 0x00177> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.SendData (System.String endpoint, System.String method, System.Net.Http.HttpContent content, ExceptionPolicy exceptionPolicy, Nullable1 timeOut) <0x5fc1d40 + 0x00667> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.String arguments, ExceptionPolicy exceptionPolicy, Nullable1 timeOut) <0x5fc0a70 + 0x00097> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.Object arguments, ExceptionPolicy exceptionPolicy, Nullable1 timeOut) <0x5fb35e0 + 0x0005f> in <filename unknown>:0 at Xamarin.UITest.iOS.HttpCalabashConnection.UIA (System.String command) <0x6b4ebb8 + 0x00093> in <filename unknown>:0 at Xamarin.UITest.iOS.iOSGestures.TapCoordinates (Single x, Single y) <0x6b4eab0 + 0x000e4> in <filename unknown>:0 at Xamarin.UITest.iOS.iOSApp+<Tap>c__AnonStorey9.<>m__0 () <0x6b4b9d8 + 0x002af> in <filename unknown>:0 at Xamarin.UITest.Utils.ErrorReporting.With (System.Action func, System.Object[] args, System.String memberName) <0x5fb20d0 + 0x00030> in <filename unknown>:0

I can also add the following output of the log.txt that Xamarin.UITest generates:

15-04-2016 10:47:00.674 +02:00 - 66310 - Tapping element matching Marked("selector") at coordinates [ 187.5, 98 ]. 15-04-2016 10:47:00.675 +02:00 - 66311 - HTTP POST { Url: { AbsolutePath: "/uia", AbsoluteUri: "http://127.0.0.1:37273/uia", Authority: "127.0.0.1:37273", Fragment: "", Host: "127.0.0.1", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: True, IsUnc: False, LocalPath: "/uia", PathAndQuery: "/uia", Port: 37273, Query: "", Scheme: "http", Segments: [ "/", "uia" ], UserEscaped: False, UserInfo: "", DnsSafeHost: "127.0.0.1", IsAbsoluteUri: True, OriginalString: "http://127.0.0.1:37273/uia" } } 15-04-2016 10:48:40.940 +02:00 - 166580 - POST Failed { StatusCode: 0, StatusDescription: "A task was canceled.", ResponseHeaders: "", Content: "" } 15-04-2016 10:48:40.942 +02:00 - 166581 - Error while performing Tap(Marked("selector")) Exception: System.Net.WebException: POST Failed at Xamarin.UITest.Shared.Http.HttpClient.HandleHttpError (System.String method, System.Exception exception, ExceptionPolicy exceptionPolicy) <0x6dd2580 + 0x00177> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.SendData (System.String endpoint, System.String method, System.Net.Http.HttpContent content, ExceptionPolicy exceptionPolicy, Nullable´1 timeOut) <0x6d54e78 + 0x00667> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.String arguments, ExceptionPolicy exceptionPolicy, Nullable´1 timeOut) <0x6d53820 + 0x00097> in <filename unknown>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.Object arguments, ExceptionPolicy exceptionPolicy, Nullable´1 timeOut) <0x6d461d8 + 0x0005f> in <filename unknown>:0 at Xamarin.UITest.iOS.HttpCalabashConnection.UIA (System.String command) <0x6db6528 + 0x00093> in <filename unknown>:0 at Xamarin.UITest.iOS.iOSGestures.TapCoordinates (Single x, Single y) <0x6db6420 + 0x000e4> in <filename unknown>:0 at Xamarin.UITest.iOS.iOSApp+<Tap>c__AnonStorey9.<>m__0 () <0x6db29f0 + 0x002af> in <filename unknown>:0 at Xamarin.UITest.Utils.ErrorReporting.With (System.Action func, System.Object[] args, System.String memberName) <0x6d44cc8 + 0x00030> in <filename unknown>:0 15-04-2016 10:48:40.944 +02:00 - 166584 - HTTP POST { Url: { AbsolutePath: "/condition", AbsoluteUri: "http://127.0.0.1:37273/condition", Authority: "127.0.0.1:37273", Fragment: "", Host: "127.0.0.1", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: True, IsUnc: False, LocalPath: "/condition", PathAndQuery: "/condition", Port: 37273, Query: "", Scheme: "http", Segments: [ "/", "condition" ], UserEscaped: False, UserInfo: "", DnsSafeHost: "127.0.0.1", IsAbsoluteUri: True, OriginalString: "http://127.0.0.1:37273/condition" } } 15-04-2016 10:48:42.060 +02:00 - 167700 - HTTP POST { Url: { AbsolutePath: "/condition", AbsoluteUri: "http://127.0.0.1:37265/condition", Authority: "127.0.0.1:37265", Fragment: "", Host: "127.0.0.1", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: True, IsUnc: False, LocalPath: "/condition", PathAndQuery: "/condition", Port: 37265, Query: "", Scheme: "http", Segments: [ "/", "condition" ], UserEscaped: False, UserInfo: "", DnsSafeHost: "127.0.0.1", IsAbsoluteUri: True, OriginalString: "http://127.0.0.1:37265/condition" } } 15-04-2016 10:48:43.593 +02:00 - 169233 - POST Complete { StatusCode: OK, StatusDescription: "OK", ResponseHeaders: "Transfer-Encoding: chunked Accept-Ranges: bytes Date: Fri, 15 Apr 2016 08:48:42 GMT ", Contents: "{"results":[],"outcome":"SUCCESS"}" }

Additional information is that the failure (nearly) only happens directly after the app start in an interaction with a Picker element.

I am using TestCloudAgent 0.19.0, Xamarin.UITest 1.3.7, OS X 10.11.4 and iOS 9.3.

Any help would be greatly appreciated.

Posts

  • Glenn.WilsonGlenn.Wilson USXamarin Team Xamurai

    @lanzelot1989 What happens if you run the same tests directly on the same machine (not via Jenkins)?

  • lanzelot1989lanzelot1989 ATMember ✭✭

    @Glenn.Wilson

    I did not manage to get this error when running the tests directly on the Mac. However, it always is the same machine where the tests are run.

    I am also using the same user which means that it probably is related to:

    • the SSH connection between the Jenkins master and the slave (which does not make any problems elsewhere) or
    • the timing of the commands or other network related configurations or
    • some Mac OS X behavior that is different (environment variables that are set, etc.).

    Could you think of other problems?

    As I mentioned before, this instability/flakyness makes the framework really hard to use for us. The workaround of always starting the tests directly on the machine also does not look very appealing.

  • JasonGilesJasonGiles USMember

    Sorry to resurrect an old thread, but we have been having similar issues with running UI Tests via Jenkins. We have no issues when running the tests locally, but when running them via Jenkins we see similar results:

    SetUp : System.IO.IOException : Unable to write data to the transport connection: The socket is not connected. ----> System.Net.Sockets.SocketException : The socket is not connected at System.Net.Sockets.NetworkStream.BeginWrite (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback callback, System.Object state) [0x000f2] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:954 at System.Net.WebConnection.BeginWrite (System.Net.HttpWebRequest request, System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback cb, System.Object state) [0x0005f] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net/WebConnection.cs:1000 --- 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.Nullable1[T] timeOut) [0x000ea] in <a8da4f6ce0844effac43db16820739eb>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.String arguments, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable1[T] timeOut) [0x00017] in <a8da4f6ce0844effac43db16820739eb>:0 at Xamarin.UITest.Shared.Http.HttpClient.PostUntilExpectedResultReceived (System.String endpoint, System.String arguments, System.String expectedContent, System.Int32 retries) [0x0001c] in <a8da4f6ce0844effac43db16820739eb>:0 --SocketException at System.Net.Sockets.Socket.BeginSend (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socket_flags, System.AsyncCallback callback, System.Object state) [0x0008d] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net.Sockets/Socket.cs:2577 at System.Net.Sockets.NetworkStream.BeginWrite (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback callback, System.Object state) [0x000b4] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:934

    When looking in the more detailed log files, this is what the last few lines of the file look like:

    22-12-2016 15:29:42.114 -05:00 - 40622 - launchable activity set as 
    22-12-2016 15:29:42.115 -05:00 - 40624 - AdbArguments: '-s 065110ef005169f5 forward tcp:50261 tcp:50261'.
    22-12-2016 15:29:42.129 -05:00 - 40638 - Finished with exit code 0 in 13 ms.
    
    22-12-2016 15:29:42.130 -05:00 - 40639 - Forwarded port 50261.
    22-12-2016 15:29:42.199 -05:00 - 40707 - HTTP POST { Url: { AbsolutePath: "/ping", AbsoluteUri: "http://127.0.0.1:50261/ping", LocalPath: "/ping", Authority: "127.0.0.1:50261", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: True, PathAndQuery: "/ping", Segments: [ "/", "ping" ], IsUnc: False, Host: "127.0.0.1", Port: 50261, Query: "", Fragment: "", Scheme: "http", OriginalString: "http://127.0.0.1:50261/ping", DnsSafeHost: "127.0.0.1", IdnHost: "127.0.0.1", IsAbsoluteUri: True, UserEscaped: False, UserInfo: "" } }
    

    Based on what I am seeing, it seems to fail on the first ping to see if the application is started. We see this on a similar frequency, between 1-4 times on a test run of about 35 tests. Usually about 1 in 5 test runs will run without error. Any information that you could give to help resolve this issue would be greatly appreciated.

  • JasonGilesJasonGiles USMember

    Sorry to resurrect an old thread, but we have been having similar issues with running UI Tests via Jenkins. We have no issues when running the tests locally, but when running them via Jenkins we see similar results:

    SetUp : System.IO.IOException : Unable to write data to the transport connection: The socket is not connected. ----> System.Net.Sockets.SocketException : The socket is not connected at System.Net.Sockets.NetworkStream.BeginWrite (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback callback, System.Object state) [0x000f2] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:954 at System.Net.WebConnection.BeginWrite (System.Net.HttpWebRequest request, System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback cb, System.Object state) [0x0005f] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net/WebConnection.cs:1000 --- 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.Nullable1[T] timeOut) [0x000ea] in <a8da4f6ce0844effac43db16820739eb>:0 at Xamarin.UITest.Shared.Http.HttpClient.Post (System.String endpoint, System.String arguments, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable1[T] timeOut) [0x00017] in <a8da4f6ce0844effac43db16820739eb>:0 at Xamarin.UITest.Shared.Http.HttpClient.PostUntilExpectedResultReceived (System.String endpoint, System.String arguments, System.String expectedContent, System.Int32 retries) [0x0001c] in <a8da4f6ce0844effac43db16820739eb>:0 --SocketException at System.Net.Sockets.Socket.BeginSend (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socket_flags, System.AsyncCallback callback, System.Object state) [0x0008d] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net.Sockets/Socket.cs:2577 at System.Net.Sockets.NetworkStream.BeginWrite (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback callback, System.Object state) [0x000b4] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:934

    When looking in the more detailed log files, this is what the last few lines of the file look like:

    22-12-2016 15:29:42.114 -05:00 - 40622 - launchable activity set as 
    22-12-2016 15:29:42.115 -05:00 - 40624 - AdbArguments: '-s 065110ef005169f5 forward tcp:50261 tcp:50261'.
    22-12-2016 15:29:42.129 -05:00 - 40638 - Finished with exit code 0 in 13 ms.
    
    22-12-2016 15:29:42.130 -05:00 - 40639 - Forwarded port 50261.
    22-12-2016 15:29:42.199 -05:00 - 40707 - HTTP POST { Url: { AbsolutePath: "/ping", AbsoluteUri: "http://127.0.0.1:50261/ping", LocalPath: "/ping", Authority: "127.0.0.1:50261", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: True, PathAndQuery: "/ping", Segments: [ "/", "ping" ], IsUnc: False, Host: "127.0.0.1", Port: 50261, Query: "", Fragment: "", Scheme: "http", OriginalString: "http://127.0.0.1:50261/ping", DnsSafeHost: "127.0.0.1", IdnHost: "127.0.0.1", IsAbsoluteUri: True, UserEscaped: False, UserInfo: "" } }
    

    Based on what I am seeing, it seems to fail on the first ping to see if the application is started. We see this on a similar frequency, between 1-4 times on a test run of about 35 tests. Usually about 1 in 5 test runs will run without error. Any information that you could give to help resolve this issue would be greatly appreciated.

  • LanceKingLanceKing USMember ✭✭
    edited January 2018

    I'm seeing this error or a similar one in multiple forum posts, but no solutions. Anyone find out what is causing this?

    "POST Failed at Xamarin.UITest.Shared.Http.HttpClient.HandleHttpError" is what I'm seeing through Xamarin Test Cloud on some older devices.

    @lanzelot1989 any guidance on how you resolved your issue?

  • lanzelot1989lanzelot1989 ATMember ✭✭

    Hi, my resolution was to switch to Appium ;-)

Sign In or Register to comment.