Can Appium server handle concurrent request to create driver?

@Aleksei
I am using 1.7.2 and tried using java executor service to create drivers concurrently on different ports. has anyone done this sucessfully?

It is not appium problem. All magic in code. You start one appium server on one port and another one on another port. You need to have 2 driver variables. One init against first server and another one with second.

yes, drivers get created when i am doing it sequentially on different ports. but invoking sequentially has a drawback since it takes quite a bit for all your devices to be ready.

I did tried code for invoking concurrently but getting some exception. I will dig further into the issue.

i do not understand you.

  1. in Thread1 start java executor and run appium1 (this is immediate code)
  2. in Thread2 start java executor and run appium2 (this is immediate code)
  3. either sleep e.g. 5sec by giving appium servers to start OR write you ping code to check is server started (i did it with simple GET HTTP request and reading an answer)
  4. now start sequentially driver1 for server1 (this will time depending on you capabilities and OS)
  5. now start sequentially driver2 for server2 (this will time depending on you capabilities and OS)
  6. execute tests
  7. close or kill Thread1 + Thread2
1 Like

@Aleksei Thanks
OK, I had an error in the callable interface implementation which i corrected and works fine now.

what I did:

  1. created a class which implements callable interface. I have port and desired capability as data type in this class.

  2. Created an executor service with thread pool size = number of attched devices.

  3. and then invoke submit on executor service.

     ExecutorService es = Executors.newFixedThreadPool(2);
    
    
     Future<AndroidDriver> sc1 = es.submit(new InvokeDriverInParallel.CreateDriverConcurrently(4725,androidCapabilities));
     Future<AndroidDriver> sc2 = es.submit(new InvokeDriverInParallel.CreateDriverConcurrently(4727,androidCapabilitiesTwo));
     try {
         System.out.println(sc1.get());
     } catch (InterruptedException e) {
         e.printStackTrace();
     } catch (ExecutionException e) {
         e.printStackTrace();
     }
    
    
     try {
         System.out.println(sc2.get());
     } catch (InterruptedException e) {
         e.printStackTrace();
     } catch (ExecutionException e) {
         e.printStackTrace();
     }

@Venkatesh mine code is old style. i am starting appium server mysef:

        // server 1
        List list = new ArrayList<String>();
        list.add("appium");
        list.add("--log-level");        
        list.add("error");
        list.add("--port");
        list.add(appiumServer1_PortPublic);
        list.add("--bootstrap-port");
        list.add(String.valueOf(Integer.parseInt(appiumServer1_PortPublic)+1000));
        list.add("--command-timeout");
        list.add("180");
        list.add("--session-override");
        list.add("--log-timestamp");

        // create the process builder
        try {
            ProcessBuilder pb1 = new ProcessBuilder(list);

            //print inputStream to console
            pb1.redirectErrorStream(true);
            pb1.redirectOutput(ProcessBuilder.Redirect.INHERIT);
            appium_Process = pb1.start();
        } catch (Exception e) {
            e.printStackTrace();
        }

and after this opening driver later against ā€˜appiumServer1_PortPublicā€™ port. Server2 and driver2 is similar.