AirtestProject / AirtestIDE

223 stars 38 forks source link

连接iOS真机频繁掉线 #464

Open soniveico opened 5 years ago

soniveico commented 5 years ago

(请尽量按照下面提示内容填写,有助于我们快速定位和解决问题,感谢配合。否则直接关闭。)

(重要!问题分类)

描述问题bug 连接iOS真机频繁掉线 截屏 强烈建议带上截图,包括IDE本身的截图和后面的黑窗口的报错信息的截图(尽量完整)。 image image image

复现步骤

  1. 执行一个需要重复操作的脚本,如200次点击,一定会出现连接失败

预期效果 正常执行

python 版本: python3.7

操作系统: macOS 10.14.4

设备:

其他相关环境信息 1.必现,只要持续跑用例,一定会复现 2.报错之后再次执行脚本可以直接执行,不需要重新连接 3.错误日志: FAILED (errors=1) ERROR: runTest (main.CustomCase)

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request six.raise_from(e, None) File "", line 2, in raise_from File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 383, in _make_request httplib_response = conn.getresponse() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse response.begin() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 257, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request six.raise_from(e, None) File "", line 2, in raise_from File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 383, in _make_request httplib_response = conn.getresponse() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse response.begin() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 257, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/airtest/cli/runner.py", line 65, in runTest six.reraise(sys.exc_info()) File "/usr/local/lib/python3.7/site-packages/six.py", line 693, in reraise raise value File "/usr/local/lib/python3.7/site-packages/airtest/cli/runner.py", line 61, in runTest exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope) File "/Users/wangxiaonan/Work/AutoTest/AirTest/case1.air/case1.py", line 12, in touch(Template(r"tpl1562844441045.png", record_pos=(-0.206, 0.836), resolution=(1125, 2436))) File "/usr/local/lib/python3.7/site-packages/airtest/utils/logwraper.py", line 72, in wrapper res = f(args, *kwargs) File "/usr/local/lib/python3.7/site-packages/airtest/core/api.py", line 257, in touch pos = loop_find(v, timeout=ST.FIND_TIMEOUT) File "/usr/local/lib/python3.7/site-packages/airtest/utils/logwraper.py", line 72, in wrapper res = f(args, kwargs) File "/usr/local/lib/python3.7/site-packages/airtest/core/cv.py", line 59, in loop_find screen = G.DEVICE.snapshot(filename=None) File "/usr/local/lib/python3.7/site-packages/airtest/core/ios/ios.py", line 159, in snapshot data = self._neo_wda_screenshot() # wda 截图不用考虑朝向 File "/usr/local/lib/python3.7/site-packages/airtest/core/ios/ios.py", line 143, in _neo_wda_screenshot value = self.driver.http.get('screenshot').value File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 129, in fetch return self._fetch_no_alert(method, url, data) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 135, in _fetch_no_alert return httpdo(target_url, method, data) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 95, in httpdo response = requests.request(method, url, json=data, timeout=HTTP_TIMEOUT) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))


[Finished]

============================================================

EraChen233 commented 5 years ago

xcode 版本是?

soniveico commented 5 years ago

xcode 版本是?

Xcode是10.2.1 就刚刚又断开一回,这次log似乎不一样,有一个iosError41 (errors=1) ERROR: runTest (main.CustomCase)

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 977, in send self.sock.sendall(data) OSError: [Errno 41] Protocol wrong type for socket

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 977, in send self.sock.sendall(data) urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(41, 'Protocol wrong type for socket'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/airtest/cli/runner.py", line 65, in runTest six.reraise(sys.exc_info()) File "/usr/local/lib/python3.7/site-packages/six.py", line 693, in reraise raise value File "/usr/local/lib/python3.7/site-packages/airtest/cli/runner.py", line 61, in runTest exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope) File "/Users/wangxiaonan/Work/AutoTest/AirTest/case1.air/case1.py", line 11, in touch(Template(r"tpl1562844431957.png", record_pos=(-0.396, 0.668), resolution=(1125, 2436))) File "/usr/local/lib/python3.7/site-packages/airtest/utils/logwraper.py", line 72, in wrapper res = f(args, kwargs) File "/usr/local/lib/python3.7/site-packages/airtest/core/api.py", line 262, in touch G.DEVICE.touch(pos, kwargs) File "/usr/local/lib/python3.7/site-packages/airtest/core/ios/ios.py", line 37, in wrapper return func(self, *args, kwargs) File "/usr/local/lib/python3.7/site-packages/airtest/core/ios/ios.py", line 223, in touch self.session.tap(x, y) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 498, in tap return self.http.post('/wda/tap/0', dict(x=x, y=y)) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 129, in fetch return self._fetch_no_alert(method, url, data) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 135, in _fetch_no_alert return httpdo(target_url, method, data) File "/usr/local/lib/python3.7/site-packages/wda/init.py", line 95, in httpdo response = requests.request(method, url, json=data, timeout=HTTP_TIMEOUT) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', OSError(41, 'Protocol wrong type for socket'))


Ran 1 test in 88.873s

FAILED [Finished]

EraChen233 commented 5 years ago

方便把你测试用的脚本,导致掉线的部分贴出来吗?

soniveico commented 5 years ago

方便把你测试用的脚本,导致掉线的部分贴出来吗?

我现在跑的脚本特别简单,就一个for循环,然后两个touch image

感觉是在循环的过程中,不确定的时间和次数,会发生掉线

EraChen233 commented 5 years ago

谢谢提供这么多信息,我晚点仔细查一下

changdapeng commented 5 years ago

我这边也频繁出现此类问题

qiangzeliang commented 2 years ago

我也是 ,真的烦躁