Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appium Service Builder takes more than 3 minutes #323

Closed
manivannan184 opened this issue Apr 3, 2019 · 10 comments
Closed

Appium Service Builder takes more than 3 minutes #323

manivannan184 opened this issue Apr 3, 2019 · 10 comments
Assignees

Comments

@manivannan184
Copy link

The problem

I am trying to start a Appium Android Service with AppiumServiceBuilder() but it takes more than 3 minutes to build

Environment

  • Appium version (or git revision) that exhibits the issue: 1.13.0-beta.0 (issue is happening with recent previous appium versions as well)
  • Last Appium version that did not exhibit the issue (if applicable): N/A
  • Desktop OS/version used to run Appium: Windows 7
  • Node.js version (unless using Appium.app|exe): 10.15.3
  • Npm or Yarn package manager: npm 6.4.1
  • Mobile platform/version under test: Android Oreo
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: Appium.Webdriver library 4.0.0.5-beta for C#

Details

I am starting Appium service for android device using below statement:

_service = new AppiumServiceBuilder().UsingPort(4723).WithLogFile(fileInfo).WithArguments(args).Build();

First time when Appium is installed, the service starts within 15 seconds.

However if i restart the Desktop or later, it takes more than 3 minutes to start the session.
(Whether the device already has Appium.settings app or not - the behavior is same)

Link to Appium logs

No appium session is created during the error time, so no logs can be provided.

Code To Reproduce Issue

var args = new OptionCollector().AddArguments(GeneralOptionList.LocalTimezone()).AddArguments(GeneralOptionList.OverrideSession());

            var fileInfo = new FileInfo(Path.Combine(CatUtilityInterface.Instance.Automationpath + @"\Appium_DEV-" +
                                                DateTime.Now.ToString("yyyy-MMM-dd_HH-mm-ss") + ".txt"));

            _service = new AppiumServiceBuilder().UsingPort(4723).WithLogFile(fileInfo).WithArguments(args).Build();

            _service?.Start();
@mykola-mokhnach
Copy link

Have you tried to start a session manually with the same arguments? How much time it takes?

@manivannan184
Copy link
Author

@mykola-mokhnach may i get the command to run manually. some sample command should help me.

@mykola-mokhnach
Copy link

mykola-mokhnach commented Apr 4, 2019

@manivannan184
Copy link
Author

@mykola-mokhnach i ran below command in CMD manually

node C:\Users\User\AppData\Roaming\npm\node_modules\appium\build\lib\main.js --local-timezone --session-override --port 4728 --address 127.0.0.1 -g C:\Work\Sync\new2.txt

Appium started quickly.

@mykola-mokhnach
Copy link

Now debug the code and get the command line generated by C# lib to compare it with one that you've executed manually. If these two are exactly the same then there might be an issue in the C# client lib

@manivannan184
Copy link
Author

manivannan184 commented Apr 8, 2019

I am debugging the appium library and found the delay happens at this statement

this.AppiumJS = this.InstalledNodeInCurrentFileSystem;

Class: AppiumServiceBuilder
Namespace: OpenQA.Selenium.Appium.Service

@manivannan184
Copy link
Author

manivannan184 commented Apr 8, 2019

sorry i closed the issue by mistake.

@manivannan184 manivannan184 reopened this Apr 8, 2019
@mykola-mokhnach
Copy link

We are not .net experts here. Moving the issue to the appropriate place

@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Apr 8, 2019
@manivannan184
Copy link
Author

delay happens at this statement

this.AppiumJS = this.InstalledNodeInCurrentFileSystem;

Class: AppiumServiceBuilder
Namespace: OpenQA.Selenium.Appium.Service

I found the recovery by adding below environmental variable:
APPIUM_BINARY_PATH
C:\Users<user>\AppData\Roaming\npm\node_modules\appium\build\lib\main.js

@laolubenson laolubenson self-assigned this Apr 9, 2019
@broetchenrackete36
Copy link
Contributor

broetchenrackete36 commented Aug 16, 2019

I did a little bit of digging and its (probably) because update-notifier doesn't have a network-connection (maybe you are behind a proxy, update-notifier doesn't honor proxy-settings). See discussion on npm-community: https://npm.community/t/npm-version-takes-3-minutes-to-complete-when-run-in-child-process-and-behind-corporate-proxy/1658/11 and pull-request npm/cli#61 .

Workarounds are to either set the environment variable APPIUM_BINARY_PATH or NO_UPDATE_NOTIFIER="true".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants