openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.38k stars 1.37k forks source link

Problems with stability of connection of a large number of devices. #900

Closed af652030 closed 1 month ago

af652030 commented 1 year ago

Problems with stability of connection of a large number of devices.

I have several mobile devices and the code on uiautomator2 which worked fine. But with increasing number of devices I catch a strange error after which something happens with adb server. After which: 1) device gets offline status 2) Log code says "device offline". 3) A window "Allow usb debugging" pops up on the device, which tells about re-authorization of the device for the adb server. Although adb server works and some other devices work stably. (It's always different devices. Sometimes it turns off device 1,2,3, sometimes 3,2,5, etc.) 4) If you use the command "adb reconnect offline" then the device can be used again and its status changes.

I have some assumptions: 1) Devices are often rebooted via "adb shell reboot" command. Perhaps when rebooting the script cannot connect to the application and a conflict occurs, so it restarts the server.

2) Problem in ports. A large number of devices require more ports and when rebooting the device as if it gets a new port. Maybe there are not enough ports and uiautomator restarts adb.

I've been studying the documentation for a couple days but can't find the reason. If you have any ideas or thoughts why the adb server might be restarting, it would be appreciated.

ERROR: ConnectionError : ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

image_2023-07-15_12-26-21

af652030 commented 1 year ago

I think it's the ports. I have 5,000 ports open on the adb.exe process.

Can you tell me where the error might be?

af652030 commented 1 year ago

Any Ideas why so many adb ports? image

Total 5200

codeskyblue commented 1 month ago

try the lastest uiautomator2 >= 3.2.0, close for now, reopen it if still exist