How to run the multiple sessions in appium server?

I have 3 PC as windows OS

PC:1
I have the Appium server.

PC:2
I have the code like

public static void startApplication() throws Exception{

	System.out.println("application has started...................");
	
	DesiredCapabilities capabilities = new DesiredCapabilities();
	
	capabilities.setCapability(CapabilityType.BROWSER_NAME, "");			
	capabilities.setCapability("deviceName","emulator-5556");	
	capabilities.setCapability("platformVersion","4.3");
	capabilities.setCapability("platformName","Android");
	capabilities.setCapability("app","D:/Apks/autoInsurance2.apk");
	driver = new RemoteWebDriver(new URL("http://172.16.10.249:4723/wd/hub"),capabilities); 
	System.out.println("Appium SetUp for Android is successful and Appium Driver is launched successfully");
}

PC: 3

I have the same code like

public static void startApplication() throws Exception{

	System.out.println("application has started...................");
	
	DesiredCapabilities capabilities = new DesiredCapabilities();
	
	capabilities.setCapability(CapabilityType.BROWSER_NAME, "");			
	capabilities.setCapability("deviceName","emulator-5554");
	capabilities.setCapability("platformVersion","4.3");
	capabilities.setCapability("platformName","Android");
	capabilities.setCapability("app","D:/Apks/QuickSales.apk");
	driver = new RemoteWebDriver(new URL("http://172.16.10.249:4723/wd/hub"),capabilities); 
	System.out.println("Appium SetUp for Android is successful and Appium Driver is launched successfully");
}

I have the 2 emulators and 2 apks. When I run the programs from PC 2 and PC 3 it should hit the PC 1 and the server should handle both the sessions. Also the different apps should open in the two different emulators. This is my expectation.

Whether this can be possible.

If so what could be the changes I need to do?

Because when I run now, either PC2/PC3 which ever is started first is running. the other one says “session exist”.

172.16.10.249 is PC1 IP address

Hi there,

I’m pretty sure you should start up 2 appium servers on your PC1, as explained here to run apps in parallels http://appium.io/slate/en/master/?javascript#parallel-android-tests

Run a default appium instance and a second one on another port.
If we had two devices with the ID’s 43364 and 32456, we would start two different Appium servers with the following commands:

node . -p 4492 -bp 2251 -U 32456

node . -p 4491 -bp 2252 -U 43364

Is it possible to run under one appium server with two different ports in a same session or different session

Whether One Appium server can handle only one port?
So if i need to handle the another port then I have to launch an another fresh appium server right
@Hassan_Radi Suggestions please

@ashokkumarg
Appium server can only handle one session and one dedicated port for that. In order to do two parallel sessions you have to start two Appium servers.

Thank you! Understood your point. When I try to do that both the applications are launching in a First emulator and the second one remains unchanged. What could be the solution?

You need to specify separate porst for each server to prevent them from using the same default values. Please read this part of the Appium documentation to get an idea on how to do it.