Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypassing adb start-server When Connecting to a Remote ADB Host #19940

Closed
omercagriyilmaz opened this issue Mar 29, 2024 · 9 comments
Closed
Labels
Android related to Android-native driver(s) Needs Info typically non-actionable; needs author to respond

Comments

@omercagriyilmaz
Copy link

Hello,

I am encountering an issue with Appium where it attempts to restart the ADB server even though I have specified a remote ADB host in my capabilities. This behavior is causing conflicts because my ADB server is already running remotely and does not need to be restarted. I am looking for a way to bypass or prevent Appium from executing the adb start-server command when initiating tests with a remote ADB host.

Here are the capabilities I'm using to define the remote ADB host and port, as well as an attempt to suppress killing the server:

caps.setCapability("appium:remoteAdbHost", "10.0.15.52");
caps.setCapability("appium:adbPort", 5055);
caps.setCapability("appium:suppressKillServer", true);

Despite these settings, Appium still attempts to start the ADB server, as seen in the logs:

[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.52 -P 5055 start-server'
[ADB] adb server version (39) doesn't match this client (41); killing...
[ADB] ADB server didn't ACK

I wish to directly proceed to the device list retrieval without Appium trying to start the ADB server, since it is already running on the remote host (10.0.15.52 on port 5055). This step seems unnecessary for my setup and causes the setup to fail.

Could you please advise on how to configure Appium to skip the adb start-server step when a remote ADB host is specified? Is there a capability or a configuration option that I'm missing, or is this an issue that needs to be addressed?

Thank you for your help.

@mykola-mokhnach
Copy link
Collaborator

Please provide the full server log

@mykola-mokhnach mykola-mokhnach added the Needs Info typically non-actionable; needs author to respond label Mar 29, 2024
@omercagriyilmaz
Copy link
Author

omercagriyilmaz commented Apr 1, 2024

This problem is solved with this merge ?

My Java Test code and Appium Logs are here.

Test Code

public static void main(String[] args) throws MalformedURLException, InterruptedException {

    DesiredCapabilities caps = new DesiredCapabilities();

    caps.setCapability("appium:automationName", "UiAutomator2");
    caps.setCapability("platformName", "Android");
    caps.setCapability("appium:platformVersion", "13");
    caps.setCapability("appium:deviceName", "R5CT31AB4FV");
    caps.setCapability("appium:udid", "R5CT31AB4FV");
    caps.setCapability("appium:ignoreHiddenApiPolicyError", true);
    caps.setCapability("appium:noReset", false);
    caps.setCapability("appium:clearDeviceLogsOnStart", true);
    caps.setCapability("appium:skipUnlock", true);
    caps.setCapability("appium:appWaitDuration", 60000);
    caps.setCapability("appium:remoteAdbHost", "10.0.15.51");
    caps.setCapability("appium:adbPort", 5055);
    caps.setCapability("appium:suppressKillServer", true);




    AndroidDriver driver = new AndroidDriver(new URL("http://10.0.15.51:4723/wd/hub"), caps);
    driver.setLocation(new Location(43.60556355969027, 27.249345463917795,  10)); 
   
    driver.quit();
}

Appium Log
[Appium] Welcome to Appium v2.5.1
[Appium] Non-default server args:
[Appium] { basePath: '/wd/hub' }
[Appium] The autodetected Appium home path: /root/.appium
[Appium] Attempting to load driver uiautomator2...
[Appium] Requiring driver at /root/.appium/node_modules/appium-uiautomator2-driver/build/index.js
[Appium] AndroidUiautomator2Driver has been successfully loaded in 0.826s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723/wd/hub
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] http://127.0.0.1:4723/wd/hub (only accessible from the same host)
[Appium] http://192.168.144.2:4723/wd/hub
[Appium] Available drivers:
[Appium] - [email protected] (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[AppiumDriver@53e1] Appium v2.5.1 creating new AndroidUiautomator2Driver (v3.0.4) session
[AppiumDriver@53e1] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@53e1] Appium's BaseDriver version is 9.5.2
[AppiumDriver@53e1] AndroidUiautomator2Driver's BaseDriver version is 9.5.2
[AndroidUiautomator2Driver@f50e] Creating session with W3C capabilities: {
[AndroidUiautomator2Driver@f50e] "alwaysMatch": {
[AndroidUiautomator2Driver@f50e] "platformName": "ANDROID",
[AndroidUiautomator2Driver@f50e] "appium:adbPort": 5055,
[AndroidUiautomator2Driver@f50e] "appium:appWaitDuration": 60000,
[AndroidUiautomator2Driver@f50e] "appium:automationName": "UiAutomator2",
[AndroidUiautomator2Driver@f50e] "appium:clearDeviceLogsOnStart": true,
[AndroidUiautomator2Driver@f50e] "appium:deviceName": "R5CT31AB4FV",
[AndroidUiautomator2Driver@f50e] "appium:ignoreHiddenApiPolicyError": true,
[AndroidUiautomator2Driver@f50e] "appium:noReset": false,
[AndroidUiautomator2Driver@f50e] "appium:platformVersion": "13",
[AndroidUiautomator2Driver@f50e] "appium:remoteAdbHost": "10.0.15.51",
[AndroidUiautomator2Driver@f50e] "appium:skipUnlock": true,
[AndroidUiautomator2Driver@f50e] "appium:suppressKillServer": false,
[AndroidUiautomator2Driver@f50e] "appium:udid": "R5CT31AB4FV"
[AndroidUiautomator2Driver@f50e] },
[AndroidUiautomator2Driver@f50e] "firstMatch": [
[AndroidUiautomator2Driver@f50e] {}
[AndroidUiautomator2Driver@f50e] ]
[AndroidUiautomator2Driver@f50e] }
[AndroidUiautomator2Driver@f50e (4ca6a637)] Session created with session id: 4ca6a637-4e9e-4f5a-9379-076911b51876
[ADB] Using 'adb' from '/opt/android/platform-tools/adb'
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 start-server'
[ADB] error: protocol fault (couldn't read status): Success
[ADB]
[AndroidUiautomator2Driver@f50e (4ca6a637)] Retrieving device list
[ADB] Trying to find connected Android devices
[ADB] Getting connected devices
[ADB] Error: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] at ADB.getConnectedDevices (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:252:11)
[ADB] at waitMs (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:309:19)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:219:20)
[ADB] at waitForCondition (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:236:10)
[ADB] at ADB.getDevicesWithRetry (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:307:5)
[ADB] at AndroidUiautomator2Driver.getDeviceInfoFromCaps (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:35:21)
[ADB] at AndroidUiautomator2Driver.createSession (/root/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:363:30)
[ADB] at AppiumDriver.createSession (/usr/lib/node_modules/appium/lib/appium.js:717:35)
[ADB] Got an unexpected error while fetching connected devices list: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] Reconnecting adb (target offline)
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 reconnect offline'
[ADB] Restarting adb
[ADB] Killing adb server on port '5055'
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 kill-server'
[HTTP] <-- POST /wd/hub/session - - ms - -
[HTTP]
[ADB] Error killing ADB server, going to see if it's online anyway
[ADB] Getting connected devices
[ADB] Error: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] at ADB.getConnectedDevices (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:252:11)
[ADB] at waitMs (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:309:19)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:219:20)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:229:14)
[ADB] at waitForCondition (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:236:10)
[ADB] at ADB.getDevicesWithRetry (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:307:5)
[ADB] at AndroidUiautomator2Driver.getDeviceInfoFromCaps (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:35:21)
[ADB] at AndroidUiautomator2Driver.createSession (/root/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:363:30)
[ADB] at AppiumDriver.createSession (/usr/lib/node_modules/appium/lib/appium.js:717:35)
[ADB] Got an unexpected error while fetching connected devices list: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] Reconnecting adb (target offline)
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 reconnect offline'
[ADB] Restarting adb
[ADB] Killing adb server on port '5055'
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 kill-server'
[ADB] Error killing ADB server, going to see if it's online anyway
[ADB] Getting connected devices
[ADB] Error: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] at ADB.getConnectedDevices (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:252:11)
[ADB] at waitMs (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:309:19)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:219:20)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:229:14)
[ADB] at spin (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:229:14)
[ADB] at waitForCondition (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:236:10)
[ADB] at ADB.getDevicesWithRetry (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:307:5)
[ADB] at AndroidUiautomator2Driver.getDeviceInfoFromCaps (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:35:21)
[ADB] at AndroidUiautomator2Driver.createSession (/root/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:363:30)
[ADB] at AppiumDriver.createSession (/usr/lib/node_modules/appium/lib/appium.js:717:35)
[ADB] Got an unexpected error while fetching connected devices list: Error while getting connected devices. Original error: Command '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 devices' exited with code 1
[ADB] Reconnecting adb (target offline)
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 reconnect offline'
[ADB] Restarting adb
[ADB] Killing adb server on port '5055'
[ADB] Running '/opt/android/platform-tools/adb -H 10.0.15.51 -P 5055 kill-server'
[ADB] Error killing ADB server, going to see if it's online anyway
[AndroidUiautomator2Driver@f50e (4ca6a637)] Deleting UiAutomator2 session
[AppiumDriver@53e1] Event 'newSessionStarted' logged at 1711955391873 (07:09:51 GMT+0000 (Coordinated Universal Time))
[AppiumDriver@53e1] Encountered internal error running command: Error: Could not find a connected Android device in 20000ms
[AppiumDriver@53e1] at ADB.getDevicesWithRetry (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/system-calls.js:332:13)
[AppiumDriver@53e1] at AndroidUiautomator2Driver.getDeviceInfoFromCaps (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:35:21)
[AppiumDriver@53e1] at AndroidUiautomator2Driver.createSession (/root/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:363:30)
[AppiumDriver@53e1] at AppiumDriver.createSession (/usr/lib/node_modules/appium/lib/appium.js:717:35)

@mykola-mokhnach
Copy link
Collaborator

In the above log I can observe

[ADB] error: protocol fault (couldn't read status): Success

error. This is an adb-specific error. Google says https://stackoverflow.com/questions/21049253/adb-devices-return-error-protocol-fault-no-status

@mykola-mokhnach mykola-mokhnach added the Android related to Android-native driver(s) label Apr 1, 2024
@mykola-mokhnach
Copy link
Collaborator

Closed because of no response

@omercagriyilmaz
Copy link
Author

First of all, I apologize for the late response. I understand the issue you're mentioning, but when I execute a similar code on the same machine, I receive a response like the one shown below.

root@7057ee6ec1c3:/home/androidusr# adb -H 10.0.15.51 -P 5055 devices
List of devices attached
R5CT31AB4FV	device

My only goal is this: For test conditions coming through UiAutomator2, I don't want it to execute the "adb start-server" command. If it doesn't attempt to start the server, the process will continue successfully.

@mykola-mokhnach
Copy link
Collaborator

mykola-mokhnach commented Apr 3, 2024

My only goal is this: For test conditions coming through UiAutomator2, I don't want it to execute the "adb start-server" command. If it doesn't attempt to start the server, the process will continue successfully.

With the most recent version of uia2 driver no start-server is going to be executed if the suppressKillServer option has been enabled

@omercagriyilmaz
Copy link
Author

I am currently setting up Appium through Docker and installing Appium via npm. Below are the relevant parts of my setup code:

# https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
RUN mkdir -p ~/.android && \
    touch ~/.android/repositories.cfg && \
    echo y | sdkmanager "platform-tools" && \
    echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" && \
    mv ~/.android .android && \
    chown -R 1300:1301 .android
ENV PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools

RUN apt-get update && apt-get install -y android-tools-adb android-tools-fastboot

When Appium starts, it logs the following information about the Appium version and the UiAutomator2 driver. It appears that the suppressKillServer feature is not working with these versions. Which version should I upgrade to?

[Appium] Welcome to Appium v2.5.1
[Appium] Non-default server args:
[Appium] { basePath: '/wd/hub' }
[Appium] The autodetected Appium home path: /root/.appium
[Appium] Attempting to load driver uiautomator2...
[Appium] Requiring driver at /root/.appium/node_modules/appium-uiautomator2-driver/build/index.js
[Appium] AndroidUiautomator2Driver has been successfully loaded in 0.836s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723/wd/hub
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] http://127.0.0.1:4723/wd/hub (only accessible from the same host)
[Appium] http://192.168.176.2:4723/wd/hub
[Appium] Available drivers:
[Appium] - [email protected] (automationName 'UiAutomator2')

@mykola-mokhnach
Copy link
Collaborator

version 3.0.5 or newer

@omercagriyilmaz
Copy link
Author

Problem solved . Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android related to Android-native driver(s) Needs Info typically non-actionable; needs author to respond
Projects
None yet
Development

No branches or pull requests

2 participants