question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to launch wda because of "Couldn't start port forwarding on port 8100. Please provide a different port using 'wdaLocalPort' capability" without delete session

See original GitHub issue

This issue happened the current master. 1.14.2 worked.

The problem

Appium fails to create a new session with useNewWDA after the first launching on a real device.

I mean:

  1. send a create session with useNewWDA: true
    • ok
  2. send a create session with useNewWDA: true
[debug] [BaseDriver] Event 'wdaStartFailed' logged at 1566837388273 (01:36:28 GMT+0900 (Japan Standard Time))
[debug] [XCUITest] Unable to launch WebDriverAgent because of xcodebuild failure: Couldn't start port forwarding on port 8100. Please provide a different port using 'wdaLocalPort' capability. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITest] Quitting and uninstalling WebDriverAgent
[XCUITest] Shutting down sub-processes
[debug] [XCUITest] Removing WDA application from device
[XCUITest] Error: Unable to launch WebDriverAgent because of xcodebuild failure: Couldn't start port forwarding on port 8100. Please provide a different port using 'wdaLocalPort' capability. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITest]     at quitAndUninstall (/Users/kazu/GitHub/appium-xcuitest-driver/lib/driver.js:505:15)
[debug] [XCUITest] Not clearing log files. Use `clearSystemFiles` capability to turn on.
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1566837388558 (01:36:28 GMT+0900 (Japan Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: Couldn't start port forwarding on port 8100. Please provide a different port using 'wdaLocalPort' capability. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[debug] [W3C]     at quitAndUninstall (/Users/kazu/GitHub/appium-xcuitest-driver/lib/driver.js:505:15)
[HTTP] <-- POST /wd/hub/session 500 1716 ms - 1293

Another error in step2

[debug] [XCUITest] Killing running processes 'xcodebuild.*242bfcc998fd156df0bd0ad1dde8ab8e0a032114' for the device 242bfcc998fd156df0bd0ad1dde8ab8e0a032114...
[XCUITest] xcodebuild exited with code '75' and signal 'null'
[debug] [XCUITest] 'pgrep -ifn xcodebuild.*242bfcc998fd156df0bd0ad1dde8ab8e0a032114' didn't detect any matching processes. Return code: 1
uncaughtException: listen EADDRINUSE: address already in use :::8100
Error: listen EADDRINUSE: address already in use :::8100
    at Server.setupListenHandle [as _listen2] (net.js:1279:14)
    at listenInCluster (net.js:1327:12)
    at Server.listen (net.js:1414:7)
    at iProxy.listen [as start] (/Users/kazu/GitHub/appium/node_modules/appium-xcuitest-driver/lib/wda/iproxy.js:33:23)
    at WebDriverAgent.start [as createIProxy] (/Users/kazu/GitHub/appium/node_modules/appium-xcuitest-driver/lib/wda/webdriveragent.js:249:14)
    at WebDriverAgent.createIProxy [as launch] (/Users/kazu/GitHub/appium/node_modules/appium-xcuitest-driver/lib/wda/webdriveragent.js:228:28)
[debug] [XCUITest] Successfully updated '/Users/kazu/GitHub/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj/project.pbxproj' with bundle id 'com.trident.WebDriverAgent'
[debug] [XCUITest] Generating xcode config file for orgId '9U4PT397Q4' and signingId 'iPhone Developer'
[debug] [XCUITest] Writing xcode config file to /var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/2019727-20152-xx57uh.t0rw/appium-temp.xcconfig

Environment

  • Appium version (or git revision) that exhibits the issue: master (xcuitest-driver was 7f3e52f03b9726eba8a6173de09db5644a3998f9)
  • Last Appium version that did not exhibit the issue (if applicable): 1.14.2
  • Desktop OS/version used to run Appium: macOS 10.14.6
  • Node.js version (unless using Appium.app|exe): 10.16.0
  • Npm or Yarn package manager: npm
  • Mobile platform/version under test:
  • Real device or emulator/simulator: real device
  • Appium CLI or Appium.app|exe:

Details

https://github.com/appium/appium-xcuitest-driver/blob/master/lib/wda/iproxy.js#L42-L48 has regression? (I haven’t dug much yet)

Link to Appium logs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
cosminstirbucommented, Sep 5, 2019

With the .NET client you can use:

private static int GetAvailablePort()
        {
            var listener = new TcpListener(IPAddress.Loopback, 0);

            listener.Start();
            int port = ((IPEndPoint)listener.LocalEndpoint).Port;
            listener.Stop();

            return port;
        }

I’m sure something similar can be done for the other clients as well (Java, etc)

1reaction
umutuzgurcommented, Aug 27, 2019

@KazuCocoa We should just do random port allocation. That would fix the wdaLocalPort issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appium (and desktop) unable to launch wda session since ...
The issue exists for all simulators. I can still use real device.. (the actual ports in errors might differ, the first one is...
Read more >
appium-xcuitest-driver - npm
This value if specified, will be used to forward traffic from Mac host to real ios devices over USB. Default value is same...
Read more >
WDA is not listening at 'http://localhost:8100/' - Appium Discuss
I'm working through the Appium Pro Intro Workshop. I'm working on Mac Catalina 10.15.4, XCode version 11.4. In the Appium Session ...
Read more >
Appium-xcuitest-driver - npm.io
This value if specified, will be used to forward traffic from Mac host to real ios devices over USB. Default value is same...
Read more >
Using Kubectl Port-Forward to Access Kubernetes Applications
Accessing an application via VM in Kubernetes isn't always simple. Readers will learn how to use the kubectl port-forward functionality to access Kubernetes ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found