appium / appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
MIT License
440 stars 179 forks source link

Original error: connect ECONNREFUSED 127.0.0.1:8100 #616

Closed pothurajtharun closed 7 months ago

pothurajtharun commented 8 months ago

While running the suite there are some test cases where we need to quit and relaunch the app. In that process I'm following the below steps.

Test Environment:

Steps followed:

  1. Launch the app using ios-deploy commands.
  2. Run some test cases both in NATIVE_APP & FLUTTER contexts.
  3. Switch to NATIVE_APP context.
  4. Terminate app ((IOSDriver) driver).terminateApp("com.xyz.xyzenterprise");

Actual Output: Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8100

Reproducibilty: 2/10 times.

Attached one of the log: appium-error.log

KazuCocoa commented 8 months ago

Perhaps the Appium/WDA process was killed by the system or something. the system log may tell more info

pothurajtharun commented 8 months ago

@KazuCocoa Today i have observed the same error three times while running a suite. Here are the timings i have observed the errors.

1st Error: 17:32:04 IST Syslog around the first error: syslog-2023_11_12_17_31_34.log

2nd Error: 17:39:58 IST Syslog around the second error: syslog-2023_11_12_17_39_27.log

3rd Error: 17:44:15 IST Syslog around the third error: syslog-2023_11_12_17_43_12.log

Appium log for the entire suite: appium-ECONNREFUSED.log

pothurajtharun commented 7 months ago

@KazuCocoa could you please take a look into the attached system logs ? Thanks!

KazuCocoa commented 7 months ago

I wondered if below lines could be related one. Btw, why did you send a new session request without quitting the previous session?

2023-11-12 12:00:44:282 [HTTP] --> POST /session/5ac19597-5f0d-425b-a98f-427ca40fefc1/context
2023-11-12 12:00:44:282 [HTTP] {"name":"FLUTTER"}
2023-11-12 12:00:44:282 [FlutterDriver@4cb0 (5ac19597)] Calling AppiumDriver.setContext() with args: ["FLUTTER","5ac19597-5f0d-425b-a98f-427ca40fefc1"]
2023-11-12 12:00:44:282 [FlutterDriver] Executing Flutter driver command 'setContext'
2023-11-12 12:00:44:283 [XCUITestDriver@4427 (7b554151)] Attempting to set context to 'NATIVE_APP' from 'NATIVE_APP'
2023-11-12 12:00:44:283 [XCUITestDriver@4427 (7b554151)] Already in 'NATIVE_APP' context. Doing nothing.
2023-11-12 12:00:44:283 [FlutterDriver@4cb0 (5ac19597)] Responding to client with driver.setContext() result: null
2023-11-12 12:00:44:283 [HTTP] <-- POST /session/5ac19597-5f0d-425b-a98f-427ca40fefc1/context 200 1 ms - 14
2023-11-12 12:00:44:283 [HTTP] 
2023-11-12 12:00:44:332 [HTTP] Request idempotency key: 6e6dc5b7-2e5e-462f-a2a9-ab7ab874ba71
2023-11-12 12:00:44:333 [HTTP] --> POST /session
2023-11-12 12:00:44:333 [HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Flutter","appium:clearDeviceLogsOnStart":true,"appium:clearSystemFiles":true,"appium:deviceName":"iPhone 8 Plus","appium:newCommandTimeout":1000,"appium:platform
...
port-4779.log","port":4779,"relaxedSecurityEnabled":true,"extraArgs":[],"allowCors":false,"allowInsecure":[],"basePath":"","callbackPort":4723,"debugLogSpacing":false,"denyInsecure":[],"keepAliveTimeout":600,"localTimezone":false,"loglevel":"debug","logNoColors":false,"logTimestamp":false,"longStacktrace":false,"noPermsCheck":false,"sessionOverride":false,"strictCaps":false,"useDrivers":[],"usePlugins":[],"driver":{"xcuitest":{"wdaLocalPort":8100}},"tmpDir":"/var/folders/9p/02fsf43s28l73q2hs_wyjm7h0000gp/T","platformName":"IOS","automationName":"Flutter","clearDeviceLogsOnStart":true,"clearSystemFiles":true,"deviceName":"iPhone 8 Plus","newCommandTimeout":1000,"platformVersion":"16","printPageSourceOnFindFailure":true,"udid":"253cb28df38fb7a0d7c97decac32071907735310","useJSONSource":true,"waitForQuiescence":false,"fastReset":true,"skipUninstall...
2023-11-12 12:00:49:037 [HTTP] <-- POST /session 200 4703 ms - 1090
2023-11-12 12:00:49:037 [HTTP] 
2023-11-12 12:01:14:285 [iProxy@253cb28d:8100] The connection has been closed
2023-11-12 12:02:01:570 [XCUITestDriver@11b2 (66dccacd)] Shutting down because we waited 1000 seconds for a command
2023-11-12 12:02:01:571 [DevCon Factory] Releasing connections for 253cb28df38fb7a0d7c97decac32071907735310 device on any port number
2023-11-12 12:02:01:572 [DevCon Factory] Found cached connections to release: ["253cb28df38fb7a0d7c97decac32071907735310:8100"]
2023-11-12 12:02:01:572 [DevCon Factory] Releasing the listener for '253cb28df38fb7a0d7c97decac32071907735310:8100'
2023-11-12 12:02:01:572 [iProxy@253cb28d:8100] Closing the connection
2023-11-12 12:02:01:572 [DevCon Factory] Cached connections count: 0
2023-11-12 12:02:01:573 [XCUITest] Not cleaning '/Users/tharunpothuraj/Library/Developer/Xcode/DerivedData/WebDriverAgent-dfezgarqmrvbedarazdnqylvbllv/Logs' folder, because the other session does not expect it to be cleaned
2023-11-12 12:02:01:574 [iProxy@253cb28d:8100] The connection has been closed
2023-11-12 12:02:01:575 [FlutterDriver@9a0d (083c40ea)] Shutting down because we waited 1000 seconds for a command
2023-11-12 12:02:01:575 [AppiumDriver@f333] Ending session, cause was 'New Command Timeout of 1000 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
2023-11-12 12:02:01:575 [AppiumDriver@f333] Removing session '083c40ea-15cb-4171-bf11-567997db3ab2' from our master session list
2023-11-12 12:02:01:575 [FlutterDriver@9a0d (083c40ea)] Deleting Flutter Driver session
2023-11-12 12:02:04:777 [HTTP] --> POST /session/21967e56-5730-41eb-a86d-7967a1e9205d/execute/sync
2023-11-12 12:02:04:777 [HTTP] {"script":"flutter:connectObservatoryWsUrl","args":[]}
2023-11-12 12:02:04:777 [FlutterDriver@e1a6 (21967e56)] Calling AppiumDriver.execute() with args
pothurajtharun commented 7 months ago

@KazuCocoa Thanks for pointing the issue. Yes there was an issue in my code to quit the driver gracefully.