Android Web app automation : Failed to start an Appium session, err was: Error: connect ECONNREFUSED

Hello,

I am trying to automate webapps on Android devices using appium.

Configuration:
Appium:V1.3.7
Android version 5.0

Code :AndroidDriver dr;
WebDriverWait myWaitVar;

	DesiredCapabilities capa = new DesiredCapabilities();
	
	capa.setCapability("deviceName", "Android");
	capa.setCapability("browserName", "Chrome");
	capa.setCapability("platformName", "Android");
	capa.setCapability("platformVersion", "5.0");
	
	try {
		dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capa);
		System.out.println("in the session");
		dr.get("www.google.com");
		
}
	catch (MalformedURLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}

Error :
info: [debug] Responding to client with error: {ā€œstatusā€:33,ā€œvalueā€:{ā€œmessageā€:ā€œA new session could not be created. (Original error: connect ECONNREFUSED)ā€,ā€œcodeā€:ā€œECONNREFUSEDā€,ā€œerrnoā€:ā€œECONNREFUSEDā€,ā€œsyscallā€:ā€œconnectā€,ā€œorigValueā€:ā€œconnect ECONNREFUSEDā€},ā€œsessionIdā€:null}

Attaching Appium logs with this post.
Please helplogs.txt (7.6 KB)

Looks like, for some reason you cannot connect to the appium server.

Thanks Sebv.

Does this problem occur in case there is some issue with Appium/Chrome Driver/Chrome browser in the smartphone i am using ? what do you think ?

No I think you just cannot reach ā€œhttp://127.0.0.1:4723ā€, you can also see in the appium log if your request ever reaches the appium server.

Hi @sebv and @AppiumUser ,

I believe the problem is not happening with "you just cannot reach ā€œhttp://127.0.0.1:4723ā€, "ā€¦ because the log (attached below by AppiumUser) is clearly shown that it is running on the same port , You just check with your Url.

Thanks,
Vijay Bhaskar.

Hi @AppiumUser,

Please make sure that your Url should be starts with http protocol -> dr.get(ā€œwww.google.comā€); should be dr.get(ā€œhttps://www.google.co.in/ā€);, The Appium Remote Url if fine with pot num 4723. and make change ā€œdeviceNameā€ as your deviceā€™s Name displayed in settings (if possible, if not then no problem).

Please have a try, hope will helps to resolve and let me know the result.

Thanks,
Vijay Bhaskar.

Yeah sorry @AppiumUser, missed the log. This is an issue with Chromedriver not starting.

1 Like

Hi Bhaskar,

Thanks for the reply. I tried changing URL.Also have mentioned path of chromedriver.exe in the system variable PATH. Still the issue is occuring. logs with this post attached.logs_06042015.txt (7.9 KB)

Hi @AppiumUser ,

Did you changed your deviceName capability? Please let me know.

Regards,
Bhaskar.

If you are able to do some debugging, the place to look is under node_modules/appium-chromedriver/lib/chromedriver.js line 58. Try to figure out whay th spawn fails.

Hi Bhaskar,
I am now getting different logs.
Recentaly i upgraded Appium to 1.4.0 .

but still no success.

Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {ā€œaddressā€:ā€œ127.0.0.1ā€,ā€œnoResetā€:true,ā€œlogNoColorsā€:true,ā€œplatformNameā€:ā€œAndroidā€,ā€œplatformVersionā€:ā€œ18ā€,ā€œautomationNameā€:ā€œAppiumā€}
info: Console LogLevel: debug
info: ā†’ POST /wd/hub/session {ā€œdesiredCapabilitiesā€:{ā€œplatformVersionā€:ā€œ5.0ā€,ā€œplatformNameā€:ā€œAndroidā€,ā€œdeviceNameā€:ā€œAndroidā€,ā€œbrowserNameā€:ā€œchromeā€,ā€œudidā€:ā€œ4d00c1e65bb9a0c1ā€}}
info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session 564c0e7d-c307-4230-8797-dfe82e1603ac
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\android-sdks\platform-tools\adb.exe
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming itā€™s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devicesā€¦
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 4d00c1e65bb9a0c1
info: [debug] Setting device id to 4d00c1e65bb9a0c1
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 wait-for-device
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell ā€œecho ā€˜readyā€™ā€
info: [debug] Starting logcat capture
info: [debug] Set chromedriver binary as: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: Set chromedriver binary as: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Pushing unlock helper app to deviceā€¦
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 install ā€œC:\Program Files\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apkā€
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell ā€œdumpsys windowā€
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to deviceā€¦
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 push ā€œC:\Program Files\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jarā€ /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all ā€˜uiautomatorā€™ processes
info: [debug] Getting all processes with ā€˜uiautomatorā€™
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell ā€œps ā€˜uiautomatorā€™ā€
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.chrome -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading jsonā€¦
info: [debug] Pushing command to appium work queue: [ā€œgetDataDirā€,{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {ā€œcmdā€:ā€œactionā€,ā€œactionā€:ā€œgetDataDirā€,ā€œparamsā€:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {ā€œstatusā€:0,ā€œvalueā€:ā€œ/data/local/tmpā€}
info: [debug] dataDir set to: /data/local/tmp
info: Killing any old chromedrivers, running: FOR /F ā€œusebackq tokens=5ā€ %a in (netstat -nao ^| findstr /R /C:"9515 ") do (FOR /F ā€œusebackqā€ %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b==ā€œā€ TASKKILL /F /PID %a))
info: No old chromedrivers seemed to exist
info: Spawning chromedriver with: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe --url-base=wd/hub --port=9515
info: [CHROMEDRIVER STDOUT] Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 9515
Only local connections are allowed.
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not proxy command to remote server. Original error: connect ECONNREFUSED
info: [debug] Error: Could not proxy command to remote server. Original error: connect ECONNREFUSED
at JWProxy.proxy$ (lib/proxy.js:121:13)
at tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:231:22)
at GeneratorFunctionPrototype.Gp.(anonymous function) [as throw] (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:264:19)
at tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.step (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:116:22)
at lib$es6$promise$$internal$$tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:319:16)
at lib$es6$promise$$internal$$invokeCallback (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:331:17)
at lib$es6$promise$$internal$$publish (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:302:11)
at lib$es6$promise$$internal$$publishRejection (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:252:7)
at Object.lib$es6$promise$asap$$flush [as _onImmediate] (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:113:9)
at processImmediate [as _immediateCallback] (timers.js:330:15)
info: [debug] Responding to client with error: {ā€œstatusā€:33,ā€œvalueā€:{ā€œmessageā€:ā€œA new session could not be created. (Original error: Could not proxy command to remote server. Original error: connect ECONNREFUSED)ā€,ā€œorigValueā€:ā€œCould not proxy command to remote server. Original error: connect ECONNREFUSEDā€},ā€œsessionIdā€:null}
info: ā† POST /wd/hub/session 500 27770.448 ms - 278

Hi,

Please try with the following code,may helps you !!!

AndroidDriver driver;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, ā€œAndroidā€));
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,ā€œ5.0.2ā€);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, ā€œGalaxy SIIIā€);// or ANDROID
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ā€œChromeā€);
driver = new AndroidDriver(new URL(ā€œhttp://0.0.0.0:4723/wd/hubā€), capabilities);

driver.get(ā€œhttps://www.google.co.in/ā€);
/* Perform your actions */.

Regards,
Bhaskar.

No it dint help. Same logs. I just wonder about the line from code
Looks like we want chrome on android ā€¦ does this mean i dont have Chrome on my device ?

HI,
Noā€¦it is saying about currently doing Web App automation on Chromeā€¦Thats it.(if you are automating Hybrid App it will show app required or something elseā€¦) .Nothing is wrong with thatā€¦!!!
And iā€™m also getting the below warning when i was upgraded to latest appium version
** " Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! " **

I guess the problem with your chrome browser version (Iā€™m not sure).Please check with others tooā€¦
Regards,
Bhaskar.

I am facing same issueā€¦ Did you find the solution?

1 Like

Yes @akrai,

Iā€™ve found the solution that I was upgraded to node to its latest version and then re-installed appium, and got resolved.

Hope this helpsā€¦!!

Regards,
Bhaskar.

@ Bhaskar
Iā€™m also facing the same issue with node < 0.12 and upgrade it. Please let me know how u have updated the node to its latest version and how you re-installed the appiumā€¦thanks in advance please help me out
Error as follows :
" > warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! "
" error: No app set; either start appium with --app or pass in an ā€˜appā€™ value in desired capabilities, or set androidPackage to launch pre-existing app on device "

1 Like

what version of node and appium did u used ?
I got the same problem

The following fixed the exact same issue for me:

  1. npm uninstall -g appium;
  2. brew upgrade npm&&node;
  3. npm install -g appium