mobly icon indicating copy to clipboard operation
mobly copied to clipboard

ERROR: "[WinError 10054]": An existing connection was forcibly closed by the remote host

Open AshrafFarhan opened this issue 1 month ago • 1 comments

Hi team in Mobly automation, sometimes I am facing an issue "[WinError 10054]", I am using: mobly version ->1.12.2

I am only using the (wired USB) ADB RPC function, not to validate automation. Any suggestions to fix or avoid this issue?

mobly.snippet.errors.Error: <AndroidDevice|<"adb id">> Encountered socket error "[WinError 10054] An existing connection was forcibly closed by the remote host" sending RPC message "{"id": 261, "method": "<function name>", "params": [<func argument>]}"
..\testEnv\lib\site-packages\mobly\controllers\android_device_lib\snippet_client_v2.py:469: in _client_receive
    return self._client.readline()
C:\Users\<username>\AppData\Local\Programs\Python\Python310\lib\socket.py:705: in readinto
    return self._sock.recv_into(b)
E   ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
..\testEnv\lib\site-packages\mobly\snippet\client_base.py:205: in rpc_call
    return self._rpc(name, *args, **kwargs)
..\testEnv\lib\site-packages\mobly\snippet\client_base.py:282: in _rpc
    response = self.send_rpc_request(request)
..\testEnv\lib\site-packages\mobly\controllers\android_device_lib\snippet_client_v2.py:434: in send_rpc_request
    self._client_send(request)
..\testEnv\lib\site-packages\mobly\controllers\android_device_lib\snippet_client_v2.py:454: in _client_send
    raise errors.Error(
E   mobly.snippet.errors.Error:  <AndroidDevice|<"adb id">> Encountered socket error "[WinError 10054] An existing connection was forcibly closed by the remote host" sending RPC message "{"id": 261, "method": "<function name>", "params": [<func argument>]}"

AshrafFarhan avatar Nov 27 '25 05:11 AshrafFarhan

Some common reasons for this error:

  1. Your physical USB connection is not stable. You can check the logcat file under the test result directory. If the USB connection broke, it will cause not only snippet socket errors but also the logcat stream to stop.
  2. Check logcat to see if the snippet server is killed or crashed. Some devices have aggressive process cleanup logic that can kill the snippet server.

mhaoli avatar Nov 28 '25 02:11 mhaoli