Subito-it / SBTUITestTunnelHost

Add Mac host tunnel to your XCTests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[SBTUITestTunnelHost] Failed to get http response for action launch'

parikhparth23 opened this issue · comments

Hello,

I am using the CocoaPods - version of SBTUITestTunnelHost 0.5.0

I am getting the following error on trying to record iOS simulator screen

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[SBTUITestTunnelHost] Failed to get http response for action launch'
terminating with uncaught exception of type NSException
CoreSimulator 857.13 - Device: iPhone 13 Pro Max (1C54B53D-2089-4503-A0B8-5F006BA59C10) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 13 Pro Max

Code:

import SBTUITestTunnelHost

class ABC: XCUITestCase {
    var commandID: UUID!
    
    override func setUpWithError() throws {
        try super.setUpWithError()
        commandID = host.launchCommand("xcrun simctl io booted recordVideo --codec=h264 --mask=black --force /Users/Jeff/Desktop/test.mov")
    }

    override func tearDownWithError() throws {
        self.host.interruptCommand(with: commandID)
        try super.tearDownWithError()
    }
    
    func testLogin() throws {
         app.launchWith()
    }
}

@tcamin can you please help with this issue?

It seems like you're not running the server application. See https://github.com/Subito-it/SBTUITestTunnelHost#mac-server-app

@tcamin ,

Sorry, i also tried with the server application running on the Mac.

I get the following error:

2022-12-08 14:00:54.538460-0800 UIEventsTests-Runner[26631:278525] [SBTUITunneledHost] Starting request for action: launch on simulator: iPhone 13 Pro Max Crash 16.1
2022-12-08 14:00:54.746213-0800 UIEventsTests-Runner[26631:278981] *** Assertion failure in -[SBTUITunneledHost performAction:data:app:], SBTUITunneledHost.m:133
2022-12-08 14:00:55.289057-0800 UIEventsTests-Runner[26631:278981] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[SBTUITestTunnelHost] Message sending failed for action launch'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018040e7ec __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x0000000180051144 objc_exception_throw + 56
	2   Foundation                          0x0000000180b13e08 _userInfoForFileAndLine + 0
	3   UIEventsTests                       0x00000002a1336d8c __44-[SBTUITunneledHost performAction:data:app:]_block_invoke.48 + 516
	4   CFNetwork                           0x0000000183df9928 CFNetwork + 31016
	5   CFNetwork                           0x0000000183e14a4c _CFHTTPMessageSetResponseProxyURL + 14648
	6   libdispatch.dylib                   0x0000000180133fa4 _dispatch_call_block_and_release + 24
	7   libdispatch.dylib                   0x0000000180135768 _dispatch_client_callout + 16
	8   libdispatch.dylib                   0x000000018013d7f8 _dispatch_lane_serial_drain + 780
	9   libdispatch.dylib                   0x000000018013e474 _dispatch_lane_invoke + 448
	10  libdispatch.dylib                   0x000000018014a624 _dispatch_workloop_worker_thread + 772
	11  libsystem_pthread.dylib             0x00000001af2568fc _pthread_wqthread + 284
	12  libsystem_pthread.dylib             0x00000001af2556c0 start_wqthread + 8
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[SBTUITestTunnelHost] Message sending failed for action launch'
terminating with uncaught exception of type NSException
CoreSimulator 857.13 - Device: iPhone 13 Pro Max Crash 16.1 (61380D39-4723-4100-8070-18594FC7EDA9) - Runtime: iOS 16.1 (20B72) - DeviceType: iPhone 13 Pro Max

Server application runnning

Screenshot 2022-12-08 at 2 03 04 PM

I was also trying to debug the issue and here is some debug logs for you:

File and line number - SBTUITunneledHost.m:133

2022-12-08 16:31:41.207616-0800 UITests-Runner[37687:446855] [SBTUITunneledHost] Starting request for action: exec on simulator: iPhone 13 Pro Max Crash 16.1
(lldb) po response
<NSHTTPURLResponse: 0x6000000db500> { URL: http://localhost:8667/exec } { Status Code: 200, Headers {
    "Cache-Control" =     (
        "no-cache"
    );
    Connection =     (
        Close
    );
    "Content-Length" =     (
        24
    );
    "Content-Type" =     (
        "application/json"
    );
    Date =     (
        "Fri, 09 Dec 2022 00:31:41 GMT"
    );
    Server =     (
        GCDWebServer
    );
} }

(lldb) po ((NSHTTPURLResponse *)response).statusCode
200

2022-12-08 16:33:36.436247-0800 UITests-Runner[37687:446855] [SBTUITunneledHost] Request for action: exec on simulator iPhone 13 Pro Max Crash 16.1 took 115.228599s
2022-12-08 16:33:36.489720-0800 UITests-Runner[37687:446855] [SBTUITunneledHost] Starting request for action: launch on simulator: iPhone 13 Pro Max Crash 16.1
2022-12-08 16:33:50.305646-0800 UITests-Runner[37687:447193] [connection] nw_socket_handle_socket_event [C2.1.1:2] Socket SO_ERROR [54: Connection reset by peer]
2022-12-08 16:33:50.305871-0800 UITests-Runner[37687:447193] [connection] nw_read_request_report [C2] Receive failed with error "Connection reset by peer"
2022-12-08 16:33:50.306211-0800 UITests-Runner[37687:447193] [connection] nw_socket_output_finished [C2.1.1:2] shutdown(16, SHUT_WR) [57: Socket is not connected]
(lldb) po ((NSHTTPURLResponse *)response).statusCode
405

(lldb) po ((NSHTTPURLResponse *)response)
<NSHTTPURLResponse: 0x60000006ee40> { URL: http://localhost:8667/launch } { Status Code: 405, Headers {
    Connection =     (
        Close
    );
    Date =     (
        "Fri, 09 Dec 2022 00:33:50 GMT"
    );
    Server =     (
        GCDWebServer
    );
} }

@tcamin hope above logs help

@tcamin can you plz look into this?

Sorry for the late reply. Did you try to build the server app from source instead of using the prebuilt binary? I need to double check but it may be outdated.

You could also check the changes in the following branch feature/xcodegen

@tcamin yes, I build the server app from the source.. no luck

Did you try running the project sample tests? I ran them this morning successfully, so I suspect the issue might be related to your project setup

Hi @tcamin ,
sorry for late reply.
My project is setup corrrectly.
The difference between the sample tests and my test is that the sample test uses - host.executeCommand and i am using host.launchCommand

issue is with the host.launchCommand

Generally you should use executeCommand. launchCommand is for more advanced usages and is therefore not even documented. That said here I've added 2 test cases that show how launchCommand can be used.

@tcamin i was able to build the server app and record the screen locally. Thank you for your help.
Closing the ticket as fixed.