appium-boilerplate icon indicating copy to clipboard operation
appium-boilerplate copied to clipboard

Appium Service and Wdio Capabilities mismatch for address and hostname

Open hborham opened this issue 2 years ago • 8 comments

Using the main branch of this repo as of eb3ad62 and I kept getting this error while running ios.app script.

2022-03-10T17:26:10.542Z ERROR webdriver: RequestError: connect ECONNREFUSED ::1:4723 at ClientRequest. (./appium-boilerplate/node_modules/got/dist/source/core/index.js:956:111) at Object.onceWrapper (node:events:640:26) at ClientRequest.emit (node:events:532:35) at ClientRequest.emit (node:domain:475:12) at ClientRequest.origin.emit (./appium-boilerplate/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20) at Socket.socketErrorListener (node:_http_client:442:9) at Socket.emit (node:events:520:28) at Socket.emit (node:domain:475:12) at emitErrorNT (node:internal/streams/destroy:164:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) 2022-03-10T17:26:10.542Z ERROR @wdio/runner: Error: Failed to create session. Unable to connect to "http://localhost:4723/", make sure browser driver is running on that address. If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.

It looks like the appium service and wdio capabilities default the hostname to 0.0.0.0 and localhost. The fix was to update either the wdio.shared.local.appium.conf.ts with address: "localhost" as an arg, OR wdio.ios.app.conf.ts with capabilities.hostname = '0.0.0.0.

Then and only then was I able to get it to work on my mac.

Links to the docs: https://webdriver.io/docs/options/#capabilities https://appium.io/docs/en/writing-running-appium/server-args/

hborham avatar Mar 10 '22 17:03 hborham

Hi @hborham

Thanks for this issue, was this based on the current project? Can you also provide some info about how your environment looks like and what you altered to the configs?

wswebcreation avatar Mar 14 '22 14:03 wswebcreation

I'm running on Monterrey (macOS).

index c4ab3ad..3eb1c31 100644
--- a/config/wdio.shared.local.appium.conf.ts
+++ b/config/wdio.shared.local.appium.conf.ts
@@ -15,6 +15,9 @@ config.services = (config.services ? config.services : []).concat([
                 // This is needed to tell Appium that we can execute local ADB commands
                 // and to automatically download the latest version of ChromeDriver
                 relaxedSecurity: true,
+                // the default is 0.0.0.0
+                // see https://appium.io/docs/en/writing-running-appium/server-args/
+                address: "localhost"
             },
         },

or setting hostname here to 0.0.0.0

index c948b59..e5d8249 100644
--- a/config/wdio.ios.app.conf.ts
+++ b/config/wdio.ios.app.conf.ts
@@ -17,6 +17,7 @@ config.capabilities = [
     {
         // The defaults you need to have in your config
         platformName: 'iOS',
+        // hostname: '0.0.0.0',
         maxInstances: 1,
         // For W3C the appium capabilities need to have an extension prefix
         // This is `appium:` for all Appium Capabilities which can be found here```

hborham avatar Mar 16 '22 23:03 hborham

hmm, this is really strange, I can run the tests on my local machine without any changes. Just trying to understand the differences between your and my setup.

  • Which version of Appium are you using?
  • How did you install it (globally/local)

wswebcreation avatar Mar 18 '22 18:03 wswebcreation

  • 1.22.2
  • globally - followed these instructions APPIUM.md

hmm, this is really strange, I can run the tests on my local machine without any changes. Just trying to understand the differences between your and my setup.

  • Which version of Appium are you using?
  • How did you install it (globally/local)

hborham avatar Mar 28 '22 17:03 hborham

Hey guys, I encourage you to push this change to master, otherwise, the mobile tests will keep failing.

ghost avatar Apr 06 '22 22:04 ghost

@arctouch-thiagowerner please raise a PR with a fix, we would be happy to merge it

christian-bromann avatar Apr 07 '22 07:04 christian-bromann

@christian-bromann can you give me permission to the repository?

ghost avatar Apr 07 '22 13:04 ghost

@arctouch-thiagowerner just fork the repository and create an upstream pull request. See also: https://gist.github.com/MarcDiethelm/7303312#contributing

christian-bromann avatar Apr 07 '22 13:04 christian-bromann

PR was merged, closing.

christian-bromann avatar Dec 15 '23 00:12 christian-bromann

i faced the same problem. so what is the correct configuration?

firmansyahrosid avatar Mar 14 '24 14:03 firmansyahrosid

@firmansyahrosid

Are you facing the same problem with the updated boilerplate?

wswebcreation avatar Mar 14 '24 16:03 wswebcreation