5

If I ran TestNG test class it displays error ------------

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. 
Original error: Could not proxy command to remote server. Original error: Error: socket hang up (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 281 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'MON-PC305', ip: '10.101.0.119', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.app.android.game.app, statBarHeight=84, noReset=false, viewportRect={top=84, left=0, width=1440, height=2308}, deviceName=emulator-5554, platform=LINUX, deviceUDID=emulator-5554, desired={app="app path", appPackage=com.app.android.game.app, appActivity=com.app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity, noReset=false, automationName=uiautomator2, skipUnlock=true, platformName=Android, deviceName=emulator-5554}, platformVersion=9, webStorageEnabled=false, automationName=uiautomator2, takesScreenshot=true, skipUnlock=true, javascriptEnabled=true, platformName=Android, deviceApiLevel=28, deviceManufacturer=Google, app=C:\Users\***\eclipse-workspace\appname\app.apk, deviceScreenSize=1440x2560, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, appActivity=com.app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity, pixelRatio=3.5, locationContextEnabled=false, deviceScreenDensity=560, deviceModel=Android SDK built for x86}]
Session ID: d275d496-08b0-4652-9aa9-67ae0476cdc8
matebende
  • 543
  • 1
  • 7
  • 21
Aditi
  • 121
  • 1
  • 1
  • 7

8 Answers8

21

Stop the appium server and execute this:

adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test

Then restart the appium server and execute your scripts.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
sunil suvarna
  • 211
  • 2
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 18 '22 at 08:11
  • worked for me, would love some info on why this happens? – Mark Mayo Aug 10 '22 at 03:30
  • 1
    i will not uninstall anything until I know a-how to reinstall it if i need b-what I am uninstalling and why; since I work in an office I need to understand and explain what I'm doing :) please can you explain why? – Don Diego Nov 30 '22 at 14:28
  • This worked for me, but can you explain why this works? – Dids Jul 20 '23 at 06:19
  • From my understanding. All this is doing is uninstalling the Appium server/test package from the android device. Simply running your tests after uninstalling will reinstall these two packages. In a nutshell, this cleans any corrupted items on your device with regards to Appium. Works well. – Tristan Heilman Aug 30 '23 at 13:14
4

I ran into an exact error but the resolution was I had to just restart both my Android emulator and also Appium server. After that everything started working.

Dharman
  • 30,962
  • 25
  • 85
  • 135
samson ojo
  • 121
  • 6
1

This happens because you have opened 2 driver instances in your code.

URL url = new URL(Common.getProperty("URL"));
driver = new AndroidDriver<WebElement>(url, capabilities);

The above stuff. Make sure you have initialized it once only in your suit otherwise it will through the same error you faced.

Syscall
  • 19,327
  • 10
  • 37
  • 52
1

I ran into exact same issue. Below are the quick solutions without uninstalling anything:

If you are using real device (Android). Remove the usb cable and switch off or restart your Android device.

If you are using emulator (Android). Shut it down and restart accordingly.

Connect your real device/emulator and run your test everything should be working accordingly

samson ojo
  • 121
  • 6
0

No sure if it is the same, but I meet similar problem on the vivo phone when I run appium automation via the uiautomator2. The appium error log is like

[debug] [W3C (9ae907c5)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up
[debug] [W3C (9ae907c5)]     at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
[HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139 ms - 530

The reason on my side of this issue is io.appium.uiautomator2.server be killed by the system process com.vivo.abe, cause I catch the following log from the logcat

02-29 09:43:32.236  1742 15589 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10271 user=0: stop by com.vivo.abe
02-29 09:43:32.236   701   701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0
02-29 09:43:32.237  1742 15589 I ActivityManager: Killing 28683:io.appium.uiautomator2.server/u0a271 (adj 0): stop by com.vivo.abe
02-29 09:43:32.239   701   701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0

The com.vivo.abe (name as Vivo Wisdom engine) is system app on vivo phone, which could not be uninstalled or force stop. There is one solution to resolve this issue, just add io.appium.uiautomator2.server to the white list, then the com.vivo.abe will not perform kill again to the app.

Method is Setting -> Battery -> High background power consumption , then add the io.appium.uiautomator2.server to the allow list.

After I perform the action, the io.appium.uiautomator2.server will not be killed again, and the automation script could run smoothly.

Hope this can give some reference to resolve the problem.

0

I also faced the similar issue. When you run into such issue, you just need to run the following command on your terminal:

adb uninstall io.appium.uiautomator2.server.test

You'll get a terminal success response. Re-run your Appium server and it will work fine.

SerjantArbuz
  • 982
  • 1
  • 12
  • 16
0

I found a workaround in the meantime: (I'm using javascript with webdriver.io, but you can adjust to other client languages, it's the same basically)

  1. Add the Full reset in Android Capabilities 'appium:fullReset': true,

  2. In afterEach Method delete the session await driver.deleteSession();

afterEach(async function () {
    await driver.deleteSession();
},2);
  1. Add 2 retries when you init the driver, in my case is the beforeEach method
beforeEach(async function () {
    driver = await getAppiumClient();        
}, 2);

Then it'll fail the first or second time with socket hang up error, but it'll be running the third and subsequent tests successfully.

Hack5
  • 3,244
  • 17
  • 37
0

I face same issue so i Uninstall the uiautomator2 and reinstall it... and my issue is resolved now

  • This looks like a comment (once you have sufficient [reputation](/help/whats-reputation) you will be able to [comment on any post](/help/privileges/comment)). To make it a real answer, please format it clearly, add details on the procedure(s) to uninstall/reinstall, and eventually give context on your specific case (did the other answers fail for you?) – mozway May 04 '23 at 07:37