Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel usage results in a "socket hang up" error. systemPort have set but still have the problem. #903

Open
Underson888 opened this issue Aug 16, 2023 · 6 comments

Comments

@Underson888
Copy link

Here's my code:

python

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
import threading

Device 1's configuration

desired_caps1 = {
"appium:appActivity": ".Settings",
"appium:appPackage": "com.android.settings",
"appium:automationName": "uiautomator2",
"appium:udid": "xxxx",
"platformName": "Android",
"appium:systemPort": 8310
}

Device 2's configuration

desired_caps2 = {
"appium:appActivity": ".Settings",
"appium:appPackage": "com.android.settings",
"appium:automationName": "uiautomator2",
"appium:udid": "192.168.137.58:5555",
"platformName": "Android",
"appium:systemPort": 8322
}

def run_test_on_device(desired_caps):
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) # Corrected URL

width = driver.get_window_size()["width"]
height = driver.get_window_size()["height"]

action = TouchAction(driver)
action.tap(x=width // 2, y=height // 2).perform()

driver.quit()

Use threading for parallel execution

thread1 = threading.Thread(target=run_test_on_device, args=(desired_caps1,))
thread2 = threading.Thread(target=run_test_on_device, args=(desired_caps2,))

thread1.start()
thread2.start()

thread1.join()
thread2.join()

I have set the different systemPort for each devices, but I still have the problem.

How can I sove that, I'm very need to be solved, thanks.

@Underson888
Copy link
Author

The error information is as follows:
Exception in thread Thread-2:
Traceback (most recent call last):
File "D:\allAi\environments\tiktok\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "D:\allAi\environments\tiktok\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "D:\tiktok\control\testParallel\test.py", line 33, in run_test_on_device
driver = webdriver.Remote('http://127.0.0.1:4723', desired_caps)
File "D:\allAi\environments\tiktok\lib\site-packages\appium\webdriver\webdriver.py", line 257, in init
super().init(
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in init
self.start_session(capabilities)
File "D:\allAi\environments\tiktok\lib\site-packages\appium\webdriver\webdriver.py", line 346, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
self.error_handler.check_response(response)
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
at UIA2Proxy.command (C:\Users\12624\AppData\Roaming\npm\node_modules\appium\node_modules@appium\base-driver\lib\jsonwp-proxy\proxy.js:355:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at AndroidUiautomator2Driver.commands.getDevicePixelRatio (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\commands\viewport.js:14:10)
at AndroidUiautomator2Driver.fillDeviceDetails (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\driver.js:256:28)
at AndroidUiautomator2Driver.createSession (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\driver.js:242:7)
at AppiumDriver.createSession (C:\Users\12624\AppData\Roaming\npm\node_modules\appium\lib\appium.js:352:35)
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\allAi\environments\tiktok\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "D:\allAi\environments\tiktok\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "D:\tiktok\control\testParallel\test.py", line 33, in run_test_on_device
driver = webdriver.Remote('http://127.0.0.1:4723', desired_caps)
File "D:\allAi\environments\tiktok\lib\site-packages\appium\webdriver\webdriver.py", line 257, in init
super().init(
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in init
self.start_session(capabilities)
File "D:\allAi\environments\tiktok\lib\site-packages\appium\webdriver\webdriver.py", line 346, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
self.error_handler.check_response(response)
File "D:\allAi\environments\tiktok\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
at UIA2Proxy.command (C:\Users\12624\AppData\Roaming\npm\node_modules\appium\node_modules@appium\base-driver\lib\jsonwp-proxy\proxy.js:355:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at AndroidUiautomator2Driver.commands.getDevicePixelRatio (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\commands\viewport.js:14:10)
at AndroidUiautomator2Driver.fillDeviceDetails (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\driver.js:256:28)
at AndroidUiautomator2Driver.createSession (C:\Users\12624.appium\node_modules\appium-uiautomator2-driver\lib\driver.js:242:7)
at AppiumDriver.createSession (C:\Users\12624\AppData\Roaming\npm\node_modules\appium\lib\appium.js:352:35)

@Underson888 Underson888 changed the title Parallel usage results in a "socket hang up" error. Parallel usage results in a "socket hang up" error. systemPort have set but still have the problem. Aug 16, 2023
@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Aug 16, 2023
@KazuCocoa
Copy link
Member

Could you share the appium log as well? (as GIST)

@Underson888
Copy link
Author

Could you share the appium log as well? (as GIST)

Ok,bro. This is the link:https://gist.github.com/Underson888/8871bca07b3241d7aa6f810e9a7bc16c

@KazuCocoa
Copy link
Member

Did they work with a single thread? The port config itself looks working

@Underson888
Copy link
Author

Did they work with a single thread? The port config itself looks working

Yes,each device is controlled by a single thread,just like the code mentioned.

@Underson888
Copy link
Author

Did they work with a single thread? The port config itself looks working

thread1 = threading.Thread(target=run_test_on_device, args=(desired_caps1,))
thread2 = threading.Thread(target=run_test_on_device, args=(desired_caps2,))

thread1.start()
thread2.start()

thread1.join()
thread2.join()

Is it correct for the driver?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants