这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@karlbaumg
Copy link

We run multiple instances of iOS Simulator on the same macOS host and each gets an IP address from a central IP address management for all simulators in the network, but when they all start WebDriverAgent, they get "address in use" errors as expected.

The suggested way of preventing this is to use USE_PORT but that introduces two challenges:

  • We need synchronization and lock for the instances running on the same host apart from IP management we already have,
  • The host must communicate back and tell which port belongs to which iOS simulator instance. With IP, we already have that information centrally so we'd always keep going to :8100 for WebDriverAgent.

This change introduces USE_IP environment variable where users can optionally change the IP that the RoutingHTTPServer binds to remove the need for host-wide synchronization for port number in scenarios where each simulator already has a known IP.

Here is how I tested it:

  1. Add the custom IP to lo0 interface so WDA can bind.
    sudo ifconfig lo0 alias 10.244.1.2
  2. Run it in a simulator with the following command:
    xcodebuild test \
      -project WebDriverAgent.xcodeproj \
      -scheme WebDriverAgentRunner \
      -destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
      USE_IP=10.244.1.2
  3. Once up and running, you'll see these log lines:
    2025-10-30 22:48:37.208232+0300 WebDriverAgentRunner-Runner[52590:11285751] Using custom binding IP address: 10.244.1.2
    2025-10-30 22:48:37.208485+0300 WebDriverAgentRunner-Runner[52590:11285751] ServerURLHere->http://10.244.1.2:8100<-ServerURLHere
    
  4. Test if it serves only on this custom IP:
    curl http://10.244.1.2:8100/health
    <!DOCTYPE html><html><title>Health Check</title><body><p>I-AM-ALIVE</p></body></html>
    curl http://127.0.0.1:8100/health
    curl: (7) Failed to connect to 127.0.0.1 port 8100 after 0 ms: Couldn't connect to server
    

When I run it with the following command, e.g. no override, I see usual behavior.

xcodebuild test \
  -project WebDriverAgent.xcodeproj \
  -scheme WebDriverAgentRunner \
  -destination 'platform=iOS Simulator,name=iPhone 16 Pro'
2025-10-30 22:53:28.503846+0300 WebDriverAgentRunner-Runner[57207:11300071] Built at Oct 30 2025 22:48:25
2025-10-30 22:53:28.517162+0300 WebDriverAgentRunner-Runner[57207:11300071] ServerURLHere->http://192.168.1.110:8100<-ServerURLHere
curl http://127.0.0.1:8100/health
<!DOCTYPE html><html><title>Health Check</title><body><p>I-AM-ALIVE</p></body></html>
curl http://192.168.1.110:8100/health
<!DOCTYPE html><html><title>Health Check</title><body><p>I-AM-ALIVE</p></body></html>

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 30, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@KazuCocoa KazuCocoa changed the title Let binding IP address to be configurable feat: Let binding IP address to be configurable via USE_IP environment variable Oct 31, 2025
…lator scenarios

Signed-off-by: Karl Baumgartner <178656887+karlbaumg@users.noreply.github.com>
Signed-off-by: Karl Baumgartner <178656887+karlbaumg@users.noreply.github.com>
Signed-off-by: Karl Baumgartner <178656887+karlbaumg@users.noreply.github.com>
@karlbaumg
Copy link
Author

Thanks @mykola-mokhnach ! I addressed all the comments and tested again with the flow in the PR description.

Signed-off-by: Karl Baumgartner <178656887+karlbaumg@users.noreply.github.com>
@karlbaumg
Copy link
Author

@mykola-mokhnach Some of the integration tests seem to be failing but they don't look related. Are they flaky? Do I need to do anything?

@mykola-mokhnach
Copy link

yes, they are sometimes flaky due to the general CI slowness. Don't worry about them. I just wanted @KazuCocoa to take another look at the PR and them we could merge it

Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg, let us merge once ci worked

wdaLocalPort?: number;
wdaRemotePort?: number;
wdaBaseUrl?: string;
wdaBindingIP?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mykola-mokhnach mykola-mokhnach merged commit 70ed7cf into appium:master Oct 31, 2025
40 of 44 checks passed
@mykola-mokhnach
Copy link

@karlbaumg Would you also like to also create a follow-up PR to https://github.com/appium/appium-xcuitest-driver ?

github-actions bot pushed a commit that referenced this pull request Oct 31, 2025
## [10.2.0](v10.1.4...v10.2.0) (2025-10-31)

### Features

* Let binding IP address to be configurable via USE_IP environment variable ([#1066](#1066)) ([70ed7cf](70ed7cf))
@github-actions
Copy link

🎉 This PR is included in version 10.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@karlbaumg
Copy link
Author

@mykola-mokhnach Sure. While doing that, I noticed some missing pieces that was uncovered when I tested end to end with the driver. #1067 is the fix for those and appium/appium-xcuitest-driver#2645 waits for that PR to be merged.

@KazuCocoa KazuCocoa added the size:S contribution size: S label Nov 1, 2025
@KazuCocoa
Copy link
Member

Hi @karlbaumg, congrats: the Appium project wants to compensate you for this contribution! Please reply to this comment mentioning @jlipps and @KazuCocoa and sharing your OpenCollective account name, so that we can initiate payment! Or let us know if you decline to receive compensation via OpenCollective. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released size:S contribution size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants