appium: 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
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:
- send a create session with
useNewWDA: true
- ok
- send a create session with
useNewWDA: true
- without
deleteSession
before this - failed because of remaining port 8100 which was used by 1
- I guessed iproxy class failed to release 8100 port in
quite()
- without
[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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 28 (18 by maintainers)
With the .NET client you can use:
I’m sure something similar can be done for the other clients as well (Java, etc)
@KazuCocoa We should just do random port allocation. That would fix the wdaLocalPort issue
@KazuCocoa I will work on a hacky solution to fix it. However, the webdriveragent.js class needs a proper refactor
mmm. https://gist.github.com/KazuCocoa/1aaa162cafdd26c0738f4be94a907c55 is the gist in step2.
I inserted some logs which had
=======
in iproxy.js tho.Someone did not release the port?, so next running iproxy failed to establish the connection, it seemed. After killing appium process and re-launching it, it worked once.
destroy
probably worked since 8100 looked listening as below.