I am facing an issue with port forwarding in my Appium setup, particularly with the UiAutomator2 server running on my Android emulator.
In the Appium server logs, I noticed the following lines:
Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
[AndroidUiautomator2Driver@6e6a (86b8ae39)] Forwarding UiAutomator2 Server port 6790 to local port 8200
[ADB] Forwarding system: 8200 to device: 6790
This indicates that the UiAutomator2 server is being forwarded from port 6790 to local port 8200 using the command (found in appium server logs):
adb -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790
However, due to restrictions in my environment (specifically, running the emulator in a container with limited open ports), I need to change the port of the UiAutomator2 server to a specific port i.e from 6790 to 2026.
I have already explored adjusting the system port by adding "systemPort": 8202 in my capabilities, but this only changes the local port to 8202 instead of addressing the issue with the UiAutomator2 server port.
Here are the capabilities I currently use for my emulator:
{
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:deviceName": "emulator-5554"
}
I have verified that the UiAutomator2 server is running properly by accessing http://127.0.0.1:6790/status in Chrome, which confirms that UiAutomator is ready to connect.
Is there a way to change the port of the UiAutomator2 server from the default port 6790 to a custom port 2026, within the Appium setup, considering the constraint of not being able to open specific ports in my environment??