【问题标题】:Appium Error: Cannot find any free port in range 8200..8299Appium 错误:在 8200..8299 范围内找不到任何空闲端口
【发布时间】:2020-11-24 01:44:12
【问题描述】:

我在 Appium(iMac 上的 Android 模拟器)中运行了大约 90 次测试,一切都很好,直到我突然开始观察到这个错误:

Starting logs capture with command: /Users/username/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
     E       selenium.common.exceptions.WebDriverException: Message: An unknown server-side
 error occurred while processing the command. Original error: Cannot find any free port in range
 8200..8299}. Please set the available port number by providing the systemPort capability or
 double check the processes that are locking ports within this range and terminate these which
 are not needed anymore

我做了一些事情来解决这个问题,但没有任何效果:

1.

adb kill-server    
adb reconnect
  1. 我确实清理了模拟器并重新启动了。

  2. 除此之外,我没有找到系统中已经使用的 8200-8299 的任何端口。

  3. 我也添加了systemPort 功能,但我仍然看到同样的错误。

我不知道如何解决这个问题。

更新:

发现更多日志并发现 UIAutomator 2(或 adb)没有清除端口转发,这就是为什么我在 iOS 上没有问题但仅在 Android 中发布。以下是 appium 服务器末尾的日志:

[debug] [35m[WD Proxy] [39m Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/d1f94433-2c44-4dac-a836-461ab7f41130] with no body
[debug] [35m[UiAutomator2] [39m Deleting UiAutomator2 server session
[debug] [35m[WD Proxy] [39m Matched '/' to command name 'deleteSession'
[debug] [35m[WD Proxy] [39m Proxying [DELETE /] to [DELETE http://127.0.0.1:8201/wd/hub/session/37137b29-a9a6-4d83-b2d9-ce510f601a2d] with no body
[debug] [35m[UiAutomator2] [39m Deleting UiAutomator2 server session

127.0.0.1:8201 上升到 127.0.0.1:8299 并删除了 100 个我没想到的活动会话。

另外,在 netstat 输出中,我确实看到 TCP 端口 127.0.0.1:8200 - 127.0.0.1:8299 (LISTEN) 是打开的

【问题讨论】:

  • 您最终找到解决方法了吗?
  • 是的,通过使用--session-override 命令行参数。
  • 非常感谢分享这个。我现在正在尝试。
  • 不幸的是,在启动 appium 服务器时添加 --session-override 标志对我的情况没有帮助。除了该标志之外,您还添加了什么?您是否同时拥有具有 systemPort 功能的 --session-override 端口 >
  • 我没有使用 systemPort 功能。我只是用了国旗。添加标志后,我在日志中注意到它没有进行端口转发,因此有 100 多个测试正在工作。添加flag后遇到什么问题?

标签: testing automated-tests appium ui-automation appium-android


【解决方案1】:

执行:

adb -s $UDID forward --remove-all

就在启动 appium 之前 并确保 adb 使用的端口是空闲的

How do I stop an adb port forward?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-19
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 2021-12-06
    • 2018-12-08
    相关资源
    最近更新 更多