Fail to use 2 instances of Appium for 2 USB connected Android devices

Which version of appium server you are using???
Configuration looks correct.

The version I’m using is 1.4.16.1

And this is in Appium in Windows machine.

in your case,

  1. You can launch two appium server instances, each server instance bind with one device. to do this you need to provide -UDID as command line argument while launching appium
    e.g: appium -p 6001 -u <Device 1 UDID>

  2. allocate different appium servers only with Unique port, and you can provide UDID to your desired capability.

Thanks,
Priyank Shah

I am having a very similar issue as you guys, I added a comment on an issue on github https://github.com/appium/appium/issues/5949#issuecomment-216656313 any help would be really appreciated.

Minor difference is that I am using Selenium as a hub, but I think the issue is stemming from the actual appium servers. It seems to be ignoring the caps? The only thing I haven’t tried is downgrading to 1.4.16, is that even worth it at this point?

Thanks!

I just skimmed the Github issue, but I think the bug occurred in one of the projects Appium depends on. npm, however, might not automatically install the latest versions of all the dependencies.

You want to install Appium through npm using the --no-shrinkwrap option, which forces npm to install the latest published versions of all the projects Appium depends on for everything.

Thanks for the quick reply @afwang, I tried that and still got the same result.

Did you do a clean install? Can you post some updated logs?

I just did a clean install of Node and Appium (with the --no-shrinkwrap option) and I am still getting the same hang up :frowning:

I attached a gist file for all the messages I am getting.

This is how I am registering the appium servers
java -jar selenium-server-standalone-2.53.0.jar -port 4444 -role hub

appium --nodeconfig appium_nodeconfig_nexus_5.json -p 4723 -bp 2251 --default-capabilities '{"udid":"192.168.60.102:5555"}'

appium --nodeconfig appium_nodeconfig_geny_nexus_7.json -p 4724 -bp 2252 --default-capabilities '{"udid":"192.168.60.101:5555"}'

I’m guessing this is a Genymotion emulator. Can you run adb help and make sure that the -s option is available? I’ve read that Genymotion packages its own version of the adb server with its emulators, and sometimes Genymotion’s adb gets used instead of the standard SDK’s version. There are some differences between the two servers.

I wouldn’t expect there to be much difference between the two, but I could be wrong. :stuck_out_tongue:

Even I ended in the same Issue. I have connected two devices to the same machine and started to different Appium servers . I was successfully able to push and launch the .Apk File(Hybrid Apk) in both the devices. But I am not able to switch between the 2 drivers for interacting. For example after logging in first driver, I’m not able to interact with 2nd driver. It shows session not found Error. Please find the logs.

org.openqa.selenium.remote.SessionNotFoundException: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
System info: host: ‘onsitelaptop’, ip: ‘192.168.56.1’, os.name: ‘Windows 8.1’, os.arch: ‘x86’, os.version: ‘6.3’, java.version: ‘1.8.0_31’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=C:\Workspace1\UCEdgeProject\UCedge\UCedge_Android_2.6.1.Xdev_debug.apk, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=BH903R1G1E, platform=LINUX, desired={app=C:\Workspace1\UCEdgeProject\UCedge\UCedge_Android_2.6.1.Xdev_debug.apk, newCommandTimeout=800, platformName=Android, udid=BH903R1G1E, deviceName=BH903R1G1E}, newCommandTimeout=800, platformVersion=5.1.1, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android, udid=BH903R1G1E}]
Session ID: 4fe65b3d-3f89-4283-a62e-ce7a6f54f215

I know it’s been awhile but I finally figured out this bug, for me at least. Include --suppress-adb-kill-server when starting your individual server nodes for selenium grid. Let me know if this works for anybody.

Problem statement: I am trying to run parallel execution with two android real device. As per @Real_Lau, I have modified my code. Can anyone help here and modify my code.

command prompt1 : appium -p 4723 -U “device id”
command prompt2 appium -p 4733 -U “device id”


from appium import webdriver
from threading import Thread

def test(deviceName,udid,port):
desired_caps = {}
desired_caps[‘automationName’] = ‘uiautomator2’
desired_caps[‘platformName’] = ‘Android’
desired_caps[‘platformVersion’] = ‘9’
desired_caps[‘deviceName’] = deviceName
desired_caps[‘udid’] = udid
desired_caps[‘Reset’] = ‘true’
desired_caps[‘appPackage’] = ‘com.sec.android.app.calculator’
desired_caps[‘appActivity’] = ‘com.sec.android.app.calculator.Calculator’
driver = webdriver.Remote(‘http://localhost:%s/wd/hub’%port, desired_caps)
driver.find_element_by_id(“com.sec.android.app.popupcalculator:id/bt_05”).click()
driver.find_element_by_id(“com.sec.android.app.popupcalculator:id/bt_add”).click()
driver.find_element_by_id(“com.sec.android.app.popupcalculator:id/bt_06”).click()
driver.find_element_by_id(“com.sec.android.app.popupcalculator:id/bt_equal”).click()
driver.find_element_by_id(“com.sec.android.app.popupcalculator:id/txtCalc”)
driver.quit()

class MyThread(Thread):
def init(self, deviceName, udid, port):
super(MyThread, self).init()
self.deviceName = deviceName
self.udid = udid
self.port = port

def run(self):
    test(self.deviceName, self.udid, self.port)

t1 = MyThread(‘Samsung S9’,‘21d8732029e’,‘4723’)
t2 = MyThread(‘Samsung A7’,‘3200b626a5af’,‘4733’)
t1.start()
t2.start()