openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.7k stars 1.42k forks source link

init 失败报ConnectionResetError(104, 'Connection reset by peer'))错误 #495

Closed cd159 closed 7 months ago

cd159 commented 5 years ago
wakelay commented 4 years ago

我也遇到了,求问怎么解决

tingsu commented 4 years ago

我同样也遇到了这个问题

uiautomator2: v2.10.0

在执行脚本的开始,连接设备的时候发生错误。

[W 200724 16:03:47 __init__:203] atx-agent has something wrong, auto recovering
[D 200724 16:03:47 __init__:286] device 127.0.0.1:5554 is online
[I 200724 16:03:47 init:155] uiautomator2 version: 2.10.0
[I 200724 16:03:47 init:352] Install minicap, minitouch
[I 200724 16:03:47 init:367] Install com.github.uiautomator, com.github.uiautomator.test 2.3.1
[I 200724 16:03:57 init:332] - app-uiautomator.apk installed
[I 200724 16:03:58 init:332] - app-uiautomator-test.apk installed
[I 200724 16:03:58 init:340] Install atx-agent 0.9.4
atx-agent_0.9.4_linux_386.tar.gz |\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff| 4.3 MB/4.3 MB
[I 200724 16:04:07 init:377] Check atx-agent version
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1356, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
XDSwang commented 4 years ago

@tingsu Check atx-agent version 注意这里,建议多init几次如果还是这里错误,说明atx-agent没正常安装运行,有的手机不能在他默认指定的文件夹运行的,需要你手动adb搞定了

tingsu commented 4 years ago

非常感谢你的回复 @XDSwang 。我的Android模拟器比较特殊,它是直接跑在VirtualBox里面的,是virtualbox-emulator. 我反复试了多次init,都是失败。但我后来尝试了老版本的uiautomator2 (2.4.3),可以正常使用了,不确定具体是什么原因?

你提到的手动adb是指 手工通过adb安装atx-agent吗?

tingsu commented 4 years ago

我对照看了 uiautomator2中对应crash的源码,我猜测是 tcp链接的时候除了问题。Check atx-agent version 这个提示,是否意味着安装atx-agent 已经成功了?

XDSwang commented 4 years ago

@是的,如果这版本能用就用这吧。

XDSwang commented 4 years ago

我对照看了 uiautomator2中对应crash的源码,我猜测是 tcp链接的时候除了问题。Check atx-agent version 这个提示,是否意味着安装atx-agent 已经成功了?

检查版本就错误了,一般说明没正常返回版本号回来,就是没正常运行,他是adb 进入指定目录,然后再adb 运行的。对于一些版本手机可能提示你没权限运行的

tingsu commented 4 years ago

谢谢回复! 谢谢这个项目,很棒。我先用着老版本。

namedlock commented 2 years ago

我使用手工初始化的方式解决问题了:https://github.com/openatx/uiautomator2/wiki/Manual-Init