DRAFT: make the adb server port configurable (appium:adbPort / CDP_ADB_PORT) - #21
Closed
gautam-jain-dev wants to merge 2 commits into
Closed
Conversation
The driver always talked to adb on 5037. ADB.createADB() was called without options in six places, so appium-adb fell back to its default, and the appium:adbPort capability that callers already send was discarded — sessions logged it under "capabilities were provided, but are not recognized". Anyone running an adb server on another port (multiple servers on one machine, a sandboxed CI agent, a device farm host with per-device servers) could not use this driver. The port now comes from, in order: the appium:adbPort capability, the CDP_ADB_PORT environment variable, then adb's default of 5037. The environment variable is not redundant. The skip-welcome-* scripts run as separate processes launched via `appium driver run`, so they never see the session's capabilities; without it the browser setup would use the requested port while the onboarding walkthrough silently used 5037. Each script now also passes the resolved port into its UiAutomator2 session, so both halves address the same adb server. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Locks in the default: with no capability and no environment variable — every existing caller — the port stays 5037, and any unusable value falls back to it rather than producing a broken -P argument. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Folded into #20 — the adb port change ships as part of the 1.0.7 release there, with the same commits plus tests covering the 5037 default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The driver can only talk to an adb server on the default port 5037.
ADB.createADB()is called with no options in six places (src/adb.jsplus eachscripts/*.js), so appium-adb falls back toDEFAULT_ADB_PORT. Callers that already passappium:adbPortget it silently dropped — a session log shows it under:That rules out any setup where adb does not listen on 5037: several adb servers on one machine, a sandboxed CI agent, or a device-farm host running one server per device.
Change
The port is resolved in this order:
appium:adbPortcapabilityCDP_ADB_PORTenvironment variablegetAdb()takes the port and passes it toADB.createADB({ adbPort }), which puts-P <port>on every adb invocation — including theforwardthat opens the devtools tunnel.Why the environment variable is not redundant
The
skip-welcome-*scripts run as separate processes, launched viaappium driver run cdp-driver skip-welcome-<browser>. They never see the session's capabilities, so a capability-only fix would leave the browser setup on the requested port while the onboarding walkthrough kept using 5037 — half-working in a way that is awkward to debug. Each script now resolves the port itself and also passes it into its UiAutomator2 session (appium:adbPort), so both halves address the same adb server.Scope
src/adb.jsresolveAdbPort();getAdb(adbPort)creates ADB with the resolved port and logs itsrc/driver.jsadbPortindesiredCapConstraints, forwardsappium:adbPorttogetAdb()scripts/{brave,opera,duckduckgo,samsung,edge}.js7 files, +42/−9. No behaviour change when the capability and the environment variable are absent: the resolver returns 5037, exactly as before.
Testing
Builds clean and every touched file parses. Not yet exercised against a real adb server on a non-default port — that is the main thing this draft needs before it should merge, along with a decision on whether
CDP_ADB_PORTis the preferred variable name.🤖 Generated with Claude Code