Are parallel Testing on multiple Android devices possible without Selenium grid

Hi,

I am trying to run tests in parallel on 2 Android devices and an emulator.
The Appium help page suggests that this is possible by setting different udids and systemPorts in the capabilities:
http://appium.io/docs/en/advanced-concepts/parallel-tests/

I am using testNG to run tests in parallel and java as language for my tests. Unfortunately, sometimes my tests fail with the error
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET

Sometimes they work and I can’t figure out, what’s the problem. I use only 2 static final members for saving the path to node and appium for starting the server. Those are only read and, obviously, never changed.

I am starting each appium service like this:

String bootstrapPort = device.getBootstrapPort(); 
        service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
                .usingAnyFreePort().withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, bootstrapPort)
                .usingDriverExecutable(new File(AppiumData.NODE_PATH))
                .withAppiumJS(new File(AppiumData.JS_PATH)));
        service.start();

When I chose different systemPorts in the capabilities, all Android tests fail. I set the udids though and use different bootstrap ports.

I have 3 questions:

  1. What is the difference of the systemPort capability and the .usingPort() method of AppiumServiceBuilder, if any?
  2. Is it possible to start parallel tests without Selenium grid at all?
  3. Is it possible to search for free ports to use for port and bootstrap port?

Help would be very much appreciated! I have already been searching the whole interent. :smiley: