Getting "Error: Android bootstrap socket crashed: Error: read ECONNRESET" when running multiple appium sessions

I installed appium from npm and have I am running my test for android on 3 real devices. Using windows OS. My tests are written in java only.

Here is how i set up the three different devices. Each testng.xml will have a property which will specify the device number so each will be set up with different capabilities.

/**
* Sets up appium.
*/
@SuppressWarnings(“deprecation”)
@BeforeSuite(alwaysRun = true)
@Parameters(“deviceNumber”)
public void SetUpAppium(String deviceNumber) throws Exception {

	DesiredCapabilities capabilities = new DesiredCapabilities();

	if (deviceNumber.equals("1")) {
		capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
		capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
		capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "0815f8ab2d9c0f04");
		capabilities.setCapability(MobileCapabilityType.UDID, "0815f8ab2d9c0f04");
		capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.ztrip.debug");
		capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,
				"com.ztrip.refresh.activity.RegistrationActivity");
		driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4923/wd/hub"), capabilities);
	} else if (deviceNumber.equals("2")) {

		capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
		capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
		capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "32048bee42301293");
		capabilities.setCapability(MobileCapabilityType.UDID, "32048bee42301293");
		capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.ztrip.debug");
		capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,
				"com.ztrip.refresh.activity.RegistrationActivity");
		driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4835/wd/hub"), capabilities);
	} else if (deviceNumber.equals("3")) {

		capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
		capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
		capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "LGH8159ea5948a");
		capabilities.setCapability(MobileCapabilityType.UDID, "LGH8159ea5948a");
		capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.ztrip.debug");
		capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,
				"com.ztrip.refresh.activity.RegistrationActivity");
		driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4747/wd/hub"), capabilities);
	}

	driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

	driver.resetApp();

I am running three different appium servers with the following command

appium --address 127.0.0.1 -p 4923 -U 0815f8ab2d9c0f04 -bp 4945 --chromedriver-port 4977 --session-override

appium --address 127.0.0.1 -p 4835 -U 32048bee42301293 -bp 4857 --chromedriver-port 4877 --session-override 

appium --address 127.0.0.1 -p 4747 -U LGH8159ea5948a -bp 4769 --chromedriver-port 4777 --session-override 

Then i use testng to execute different test cases on each real device. However, 10 minutes into the test cases i get the following error on two of the servers. The third server contineus to work normally.

Error: Android bootstrap socket crashed: Error: read ECONNRESET
at Socket. (lib/bootstrap.js:87:21)
at Socket.emit (events.js:107:17)
at net.js:459:14
at process._tickCallback (node.js:355:11)

I have updated appium to latest version with npm update -g appium

Please help as I have been stuck on this issue for over a week. I believe there may be a bug where appium is not correctly forwarding the bootstrap port.

@SrinivasanTarget @imurchie @bootstraponline could some please help me on this… this is on appium 1.5.3

  1. Go to task manger and kill all the adb server
  2. Close eclipse .
  3. Open eclipse and run your script

Thanks for your reply. However this did not solve my issue. Tried restarting the machine as well.

You are not using selenium grid

@Jitu1888 yes you are right i was not. I switched to selenium grid but still see the same error. I see all three of my devices registered in selenium grid. I then run testng.xml for each device and the same bootstrap socket crash occurs.

Ok i will share my code and you can add your device udid

@Jitu1888 Thank you, that would be great help. How could i access your code?

i am writing the code with 4 devices and i will share you on Monday

Thank you that would be much help

Node Config:

  1. First Device
    {
    “capabilities”:
    [
    {
    “browserName”: “Android”,
    “version”:“6.0.1”,
    “maxInstances”: 5,
    “platform”:“ANDROID”,
    “deviceName”:“192.168.71.110:5555”
    }],

    “configuration”:
    {
    “nodeTimeout”:120,
    “port”:4723,
    “hubPort”:4444,
    “proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
    “url”:“http://127.0.0.1:4723/wd/hub”,
    “hub”: “127.0.0.1:4444/grid/register”,
    “hubHost”:“127.0.0.1”,
    “nodePolling”:2000,
    “registerCycle”:10000,
    “register”:true,
    “cleanUpCycle”:2000,
    “timeout”:300000,
    “maxSession”:1
    }
    }

2.Second Device
{
“capabilities”:
[
{
“browserName”: “Android”,
“version”:“6.0.1”,
“maxInstances”: 5,
“platform”:“ANDROID”,
“deviceName”:“192.168.71.112:5555”
}],

"configuration":

{
“nodeTimeout”:120,
“port”:4725,
“hubPort”:4444,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://127.0.0.1:4725/wd/hub”,
“hub”: “127.0.0.1:4444/grid/register”,
“hubHost”:“127.0.0.1”,
“nodePolling”:2000,
“registerCycle”:10000,
“register”:true,
“cleanUpCycle”:2000,
“timeout”:300000,
“maxSession”:1
}
}

  1. First run selenium Server.
    2.(gridserver.batch file)
    Selenium Server
    cd C:\Users\Jitu.patel\android-sdks
    java -jar selenium-server-standalone-2.53.0.jar -port 4444 -role hub http://127.0.0.1:4444/grid/console

Script:
package packsage4cleints;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Parameters;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class test4cleints {

AndroidDriver<WebElement> androidDriver;
WebDriver driver;
@Parameters({"port","device"})

public void sagemaxconnect(String port,String device) throws MalformedURLException, InterruptedException{

	for (int i = 0; i<=100 ;i++)
	{
		System.out.println("iteration "+i+" started" );
		DesiredCapabilities capability =new DesiredCapabilities();
		capability.setCapability("noReset","true");
		capability.setCapability("fullReset","false");
		capability.setCapability("deviceName","Nexus 5");
		capability.setCapability("plateformName","Android");
		capability.setCapability("plateformVersion","6.0.1");
		capability.setCapability("appPackage", "com.echostar.ha.sageApp");
		capability.setCapability("appActivity","com.echostar.ha.sageApp.SageMainUiActivity");
		capability.setCapability(MobileCapabilityType.DEVICE_NAME, device);
		
		
		driver = new AndroidDriver<>(new URL("http://localhost:"+port+"/wd/hub"), capability);
		File file = new File("C:\\Users\\navjit.singh\\workspace\\SageMaxClientproject\\apk\\SageHAApp_final.apk");
		capability.setCapability(MobileCapabilityType.APP, file);
		/*capability.setCapability("app",file.getAbsolutePath());*/
		
		/*androidDriver = new AndroidDriver<>(new URL("http://192.168.71.142:4723/wd/hub"), capability);
		*/
		Thread.sleep(30000);
		androidDriver.findElement(By.id("com.echostar.ha.sageApp:id/sage_cameras_button")).click();
		Thread.sleep(30000);
		System.out.println("iteration "+i+" stop");
	}
		driver.quit();
		
}

}

Follow the above link

  1. Testng.xml : You can copy from the link
    https://www.youtube.com/watch?v=veAsmpwutKk2*

Reference code code:-

@Jitu1888 Thank you with your help i was able to properly set up selenium grid and run my tests. I haven’t seen the bootstrap socket crash so i believe the problem is fixed. Thanks again for your time!

1 Like