Skip to content

Request method "dumpWindowHierarchy" may cause exception "http.client.RemoteDisconnected: Remote end closed connection without response" #1120

@vskarinov

Description

@vskarinov
  • Python 3.10
  • uiautomator2 == 3.3.3

When I call method get from uiautomator2.xpath.XPathSelector with args 'timeout' not None, i may get exception "http.client.RemoteDisconnected: Remote end closed connection without response"

According to trace, eventually we call method get_page_source from uiautomator2.xpath.XPathEntry that sends rpc request:

method: POST
path: /jsonrpc/0
body: {"jsonrpc": "2.0", "id": 1, "method": "dumpWindowHierarchy", "params": [false, 50]} | {'User-Agent': 'uiautomator2', 'Accept-Encoding': '', 'Content-Type': 'application/json'}

we fail to get response with _response = conn.getresponse() from core.py

Here is a piece of my trace:

File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 427, in get
if not self.wait(timeout or self._global_timeout):
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 456, in wait
if self.exists:
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 412, in exists
return len(self.all()) > 0
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 388, in all
source = self._get_page_source()
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 383, in _get_page_source
return self._parent.get_page_source()
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/xpath.py", line 197, in get_page_source
return PageSource.parse(self._d.dump_hierarchy())
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/init.py", line 107, in dump_hierarchy
content = self._do_dump_hierarchy(compressed, max_depth)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/decorator.py", line 235, in fun
return caller(func, *(extras + args), **kw)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/retry/api.py", line 90, in retry_decorator
return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/retry/api.py", line 35, in __retry_internal
return f()
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/init.py", line 122, in _do_dump_hierarchy
content = self.jsonrpc.dumpWindowHierarchy(compressed, max_depth)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/base.py", line 158, in call
return self.server.jsonrpc_call(self.method, params, http_timeout)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/core.py", line 311, in jsonrpc_call
return _jsonrpc_call(self._dev, self._device_server_port, method, params, timeout, self._debug)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/core.py", line 173, in _jsonrpc_call
r = _http_request(dev, device_port, "POST", "/jsonrpc/0", payload, timeout=timeout, print_request=print_request)
File "/Users/v.skarinov/.pyenv/versions/auto_tools/lib/python3.10/site-packages/uiautomator2/core.py", line 140, in _http_request
_response = conn.getresponse()
File "/Users/v.skarinov/.pyenv/versions/3.10.15/lib/python3.10/http/client.py", line 1375, in getresponse
response.begin()
File "/Users/v.skarinov/.pyenv/versions/3.10.15/lib/python3.10/http/client.py", line 318, in begin
version, status, reason = self._read_status()
File "/Users/v.skarinov/.pyenv/versions/3.10.15/lib/python3.10/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions