Appium appium iOS macos 经常出现 ConnectionResetError: [Errno 54] Connection reset by peer,pyhon 版本 3.7,白苹果

haha269 · 2019年11月20日 · 最后由 haha269 回复于 2020年06月18日 · 4662 次阅读

错误
ft7.1: Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.7.5/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 "/Users/mango/Downloads/MangoMis_ios/testsuites/test_10_mis_list_search.py", line 61, in test_2_search_maimai
self.driver.find_element_by_ios_predicate("type == 'XCUIElementTypeButton' AND name == '小区名/拼音/地址/房源编号'").click()
File "/usr/local/lib/python3.7/site-packages/appium/webdriver/webdriver.py", line 358, in find_element_by_ios_predicate
return self.find_element(by=MobileBy.IOS_PREDICATE, value=predicate_string)
File "/usr/local/lib/python3.7/site-packages/appium/webdriver/webdriver.py", line 276, in find_element
'value': value})['value']
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
method, url, fields=fields, headers=headers, **urlopen_kw
File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.7.5/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'))

共收到 14 条回复 时间 点赞

大佬,解决了吗?我黑果也老是遇到这情况,莫名其妙

这个实际上不会影响测试流程吧
socket 默认连接 60 秒,如果 60 秒你什么都没干,那么如果手机 server 也好,还是电脑这边只要发送了事件
大概率会报这个 by peer

os 回复

自动断电,报错了 直接就......困扰好久了,到现在没有确诊,好像是 post 包体过长造成的,,,,也可能是 OpenSSL,,,,,,反正什么招都试了,依然如此

洛凉 回复

我刚开始以为是黑苹果的事,换了白苹果一样 你看看 你 OpenSSL 升级试试 反正我是不好使

haha269 回复

OPenSSL 试过了也一样,应该是版本兼容问题,我之前用 3.8 经常遇到这问题,现在 3.7。5 暂时没遇到了

洛凉 回复

我就是 3.7.5 你 OpenSSL 版本多少 我试试 好像合信息头数据过大有关

之前也遇到此问题,解决方案,以下几点,你逐一试试吧,
1.python3.7.3 升级为 python3.7.4 版本,上一版本有此问题
2.openssl 升级版本
3.防火墙看看关了吗?查看代码是否有循环请求,在同一命令循环快速请求时,报此错误
4.安装 conda,python 和 python3 都指向了 conda(实际就这个方法,碰对了)
挨个试试吧,试了多长时间我就不说了,反正坑到头了

haha269 回复

你说的方法我都试过了,都不好使啊。问题仍然存在。
conda 这个是只要安装它就可以么?

还是有其他的办法可以解决?

我有时候感觉是 WiFi 的问题呢

jz373 回复

暂时没有 conda 只是见效一段时间,问题还是处在重置问题上,我打算改用 java 写一个了,可以肯定的是 Python 和 mac 兼容问题,很困扰头疼

haha269 回复

我 mac 就直接用终端启动 appium,这个问题的出现频率就很少了,你可以试试

jz373 回复

最近升级 appium1.15.1 了 改用 13.3 的手机基本没发生过,之前用的是 12.4 ipad 时长发生此问题,macos10.15.3+appium1.15.1+python3.7+xcode11.3 目前比较稳定,iPhone 很稳定,ipad 偶尔出现中断 (怀疑硬件问题),Android 也偶尔出现此问题.....好在 PC 比较多,服务器也多

haha269 回复

我用 appium1.15.1 ,iOS 特别不稳定,经常连不上,要不停尝试。。。
不知道杀原因。

季文洪 回复

xcode11.3.1 确认安装了?

haha269 回复

xcode11.3.1 升级 11.4 吧 appium 1.15.1 升级 1.17.1 稳定性 好太多了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册