Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多台设备,USB没问题,Wifi就会随机几台设备出现adbutils.errors.AdbError: unknown host service #938

Closed
duffercn opened this issue Feb 7, 2024 · 2 comments

Comments

@duffercn
Copy link

duffercn commented Feb 7, 2024

连了8台手机,型号一样,都是小米Note 11。
用USB连接的时候可以正常工作,不会报Bug。但是用Wifi连接的时候,差不多一旦超过3台设备,就会出问题。本次出现的具体问题不一样,但最终一般都落到了这个问题上:
adbutils.errors.AdbError: unknown host service
我在想,是因为网络不如USB稳定,所以Axagent 不能及时返回操作结果,然后再ADB就会出问题吗?求教!

  • 手机型号
    多台小米Note 11

  • uiautomator2的版本号(pip show uiautomator2)
    Name: uiautomator2
    Version: 2.16.25
    Summary: Python Wrapper for Google Android UiAutomator2 test tool
    Home-page: https://github.com/openatx/uiautomator2
    Author: codeskyblue
    Author-email: codeskyblue@gmail.com
    License: MIT
    Location: /Users/ZhenLi/miniconda3/lib/python3.10/site-packages
    Requires: adbutils, cached-property, Deprecated, filelock, logzero, lxml, packaging, Pillow, progress, requests, retry, six, whichcraft
    Required-by: weditor

  • 相关日志(Python控制台错误信息, adb logcat完整信息, atxagent.log日志)
    Exception in thread Thread-4 (manage_users):
    Traceback (most recent call last):
    File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    [I 240207 15:36:37 init:357] [pid:3041] [192.168.1.102] wait-for-device, time left(3.0s)
    Exception in thread Thread-1 (manage_users):
    Traceback (most recent call last):
    File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
    File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self.run()
    File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/main.py", line 54, in manage_users
    self._target(*self._args, **self._kwargs)
    if not app.switch_user():
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/main.py", line 54, in manage_users
    if not app.switch_user():
    ^^^^^^^^^ ^^^ ^ ^ ^ ^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/douyin_interaction.py", line 882, in switch_user
    ^^^^^^^^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/douyin_interaction.py", line 882, in switch_user
    user_name_element = switch_button_element.left(className="android.widget.TextView")
    user_name_element = switch_button_element.left(className="android.widget.TextView")
    ^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 468, in left
    ^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 468, in left
    return self.__view_beside(onleftof, **kwargs)
    return self.__view_beside(onleftof, **kwargs)
    ^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 488, in __view_beside
    ^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 488, in __view_beside
    dist = onsideof(bounds, ui.info["bounds"])
    dist = onsideof(bounds, ui.info["bounds"])
    ^ ^ ^^^^^^^^^^
    ^ File "", line 2, in info
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/retry/api.py", line 73, in retry_decorator

    File "", line 2, in info
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/retry/api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
    ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/retry/api.py", line 33, in __retry_internal
    ^^^^^^^^^^^^^^^^^^^ return f()
    ^^^ ^ ^ ^ ^^^ ^^^ ^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 130, in info
    ^^^^^^^^^^^^^^^^^^^ return self.jsonrpc.objInfo(self.selector)^^^
    ^ ^^^^ ^ ^ ^ ^^^^^^^^
    ^^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/retry/api.py", line 33, in __retry_internal
    ^^^^^^^ ^^^return f()
    ^ ^^^ ^ ^ ^ ^^^^^
    ^^^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/_selector.py", line 130, in info
    ^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 479, in call
    return self.jsonrpc.objInfo(self.selector)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 479, in call
    return self.server._jsonrpc_retry_call(self.method, params,
    return self.server._jsonrpc_retry_call(self.method, params,
    ^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 486, in _jsonrpc_retry_call
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 486, in _jsonrpc_retry_call
    return self._jsonrpc_call(*args, **kwargs)
    return self._jsonrpc_call(*args, **kwargs)
    ^^ ^ ^ ^ ^ ^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 513, in _jsonrpc_call
    ^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 513, in _jsonrpc_call
    res = self.http.post("/jsonrpc/0",
    res = self.http.post("/jsonrpc/0",
    ^^^ ^ ^^^ ^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
    ^^^^^^^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs) return self.request("POST", url, data=data, json=json, **kwargs)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    

    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 223, in request
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 223, in request
    self.__client._prepare_atx_agent()
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 314, in _prepare_atx_agent
    self.__client._prepare_atx_agent()
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 314, in _prepare_atx_agent
    _d = self._wait_for_device()
    ^^^^^ _d = self._wait_for_device()
    ^ ^^^ ^ ^ ^ ^ ^ ^^^^^^^^^^^^^^^^^^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 367, in _wait_for_device
    ^^^^^^^^^^ adb.wait_for(self._serial, timeout=1)^
    ^ File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 218, in wait_for
    ^
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 367, in _wait_for_device
    adb.wait_for(self._serial, timeout=1)
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 218, in wait_for
    c.check_okay()c.check_okay()

    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 134, in check_okay
    File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 134, in check_okay
    raise AdbError(self.read_string_block()) raise AdbError(self.read_string_block())
    adbutils.errors.AdbError: unknown host service

adbutils.errors.AdbError: unknown host service
[W 240207 15:36:37 init:218] [pid:3041] atx-agent has something wrong, auto recovering
[I 240207 15:36:37 init:357] [pid:3041] [192.168.1.102] wait-for-device, time left(3.0s)
Exception in thread Thread-7 (manage_users):
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/main.py", line 53, in manage_users
app.start_app()
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/douyin_interaction.py", line 24, in start_app
self.ensure_at_base_screen()
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/douyin_interaction.py", line 40, in ensure_at_base_screen
if element.exists:
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/utils.py", line 105, in bool
return self.nonzero()
^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/utils.py", line 101, in nonzero
return self.uiobject.jsonrpc.exist(self.uiobject.selector)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 479, in call
return self.server._jsonrpc_retry_call(self.method, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 486, in _jsonrpc_retry_call
return self._jsonrpc_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 513, in _jsonrpc_call
res = self.http.post("/jsonrpc/0",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 223, in request
self.__client._prepare_atx_agent()
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 314, in _prepare_atx_agent
_d = self._wait_for_device()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/uiautomator2/init.py", line 367, in _wait_for_device
adb.wait_for(self._serial, timeout=1)
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 218, in wait_for
c.check_okay()
File "/Users/ZhenLi/PycharmProjects/mobile_control_v2/venv/lib/python3.11/site-packages/adbutils/_adb.py", line 134, in check_okay
raise AdbError(self.read_string_block())
adbutils.errors.AdbError: unknown host service

@codeskyblue
Copy link
Member

更新到3.x试试

@Louis24
Copy link

Louis24 commented May 24, 2024

更新到3.x试试

为什么之前好好的啊 我在win10可以 win11 的ui和adb的版本跟之前完全一样
是因为dependency变了么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants