Unknown server issue socket hang up

I got this issue with something like this:

[debug] e[35m[W3C (58f83265)]e[39m 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: socket hang up
[debug] e[35m[W3C (58f83265)]e[39m at UIA2Proxy.command (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:274:13)
[debug] e[35m[W3C (58f83265)]e[39m at runMicrotasks ()
[debug] e[35m[W3C (58f83265)]e[39m at processTicksAndRejections (internal/process/task_queues.js:95:5)
[debug] e[35m[W3C (58f83265)]e[39m at AndroidUiautomator2Driver.helpers.doFindElementOrEls (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\commands\find.js:30:12)
[debug] e[35m[W3C (58f83265)]e[39m at doFind (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:36:17)
[debug] e[35m[W3C (58f83265)]e[39m at wrappedCondFn (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\timeout.js:151:12)
[debug] e[35m[W3C (58f83265)]e[39m at spin (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:138:20)
[debug] e[35m[W3C (58f83265)]e[39m at waitForCondition (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:154:10)
[debug] e[35m[W3C (58f83265)]e[39m at AndroidUiautomator2Driver.implicitWaitForCondition (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\timeout.js:153:10)
[debug] e[35m[W3C (58f83265)]e[39m at AndroidUiautomator2Driver.findElOrEls (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:60:5)
[debug] e[35m[W3C (58f83265)]e[39m at AndroidUiautomator2Driver.findElOrElsWithProcessing (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\find.js:33:12)
[debug] e[35m[W3C (58f83265)]e[39m at AndroidUiautomator2Driver.findElementsFromElement (C:\Users\amb3942\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\find.js:71:10)

Somehow it is related to node js but I am not sure how do I start to resolve this issue, anyone knows about this issue?

give a bit more info when it happens and how often

Hi sure, I have a test suite (TestNG) that has few Appium test cases in it and then execute with gradlew command, it is running fine in my local machine but it’s not when I use some sort of Jenkins to trigger some batch file to execute gradlew command so that it will starts run the Appium test cases. It is running fine until one specific test case (not the test case issue), around 17 minutes and then the unknown server issue like the log above keep showing up and thus failed the rest of the test cases. It happens every single time I trigger Jenkins job and execute the gradlew command to run the Appium test cases

I have tried various method and it’s not resolving this issue:

disable battery power optimization
disconnect adb after one test suite executed
change new connection cable for device
factory reset
uninstall appium apk
task kill node.exe
change new LAN cable
set Appium time idle timeout to 100

so TestNG.

  1. you should start appium servers in beforeSuite and stop servers afterSuite.
  2. you should open driver in beforeMethod and quit in afterMethod
  3. are you running tests in parallel or with one device?
  1. I already set start Appium server in BeforeSuite and then stop the server AfterSuite, it is AppiumDriverLocalService, is that right?
  2. You mean every time I create a driver from DriverManager I need to close it at afterMethod?
  3. So far I only run tests with one device, but in the future I want to make it so that it can support two radios interaction test
  1. any way you like. e.g. start in Java command executor.
  2. yes in most cases.

Hi, when you said that I need to close the driver in every method, the driver you referring to is the setCapability thing, right?

Right. In beforeMethod you start driver with some capabolities. And in afterMethod you quit driver.