title: Webdriverio Cucumberjs tests for a React Native app fails on AWS Device Farm - Socket hang up
body: <p>I'm writing End-to-ends tests for a React Native app using <a href="https://webdriver.io/" rel="nofollow noreferrer">WebdriverIo</a>, <a href="http://appium.io/" rel="nofollow noreferrer">Appium</a> and <a href="https://cucumber.io/docs/installation/javascript/" rel="nofollow noreferrer">Cucumberjs</a> and deploying the tests on the <a href="https://aws.amazon.com/device-farm/" rel="nofollow noreferrer">AWS Device Farm</a>. </p>
  
  <p>The tests are working fine both on the Android simulator and on an actual real device. Though, on AWS, it throws errors such as <code>(node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"</code> and <code>RequestError: socket hang up</code>. This is shown in more detail below:</p>
  
  <pre class="lang-js prettyprint-override"><code>[DeviceFarm] echo "Start Appium Node test"
  Start Appium Node test
  [DeviceFarm] npm run only-one-test-aws
  
  &gt; e2e-cucumber-wdio-appium@1.0.0 only-one-test-aws /tmp/scratch0EgKio.scratch/test-packageFvDXet
  &gt; npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
  
  
  Execution of 1 spec files started at 2020-06-04T18:23:19.220Z
  
  2020-06-04T18:23:19.223Z INFO @wdio/cli:launcher: Run onPrepare hook
  2020-06-04T18:23:19.254Z INFO @wdio/cli:launcher: Run onWorkerStart hook
  2020-06-04T18:23:19.256Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.android.conf.js,--spec,./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
  [0-0] 2020-06-04T18:23:20.961Z INFO @wdio/local-runner: Run worker command: run
  [0-0] 2020-06-04T18:23:21.062Z DEBUG @wdio/local-runner:utils: init remote session
  [0-0] 2020-06-04T18:23:21.095Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
  [0-0] RUNNING in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
  [0-0] 2020-06-04T18:23:22.697Z DEBUG @wdio/local-runner:utils: init remote session
  [0-0] 2020-06-04T18:23:22.714Z INFO webdriverio: Initiate new session using the webdriver protocol
  [0-0] 2020-06-04T18:23:22.717Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
  [0-0] 2020-06-04T18:23:22.717Z INFO webdriver: DATA {
    capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
    desiredCapabilities: {}
  }
  [0-0] (node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"
  [0-0] 2020-06-04T18:24:52.853Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
  [0-0] 2020-06-04T18:24:52.856Z INFO webdriver: Retrying 1/3
  [0-0] 2020-06-04T18:24:52.857Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
  [0-0] 2020-06-04T18:24:52.857Z INFO webdriver: DATA {
    capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
    desiredCapabilities: {}
  }
  [0-0] 2020-06-04T18:24:54.004Z DEBUG webdriver: request failed due to response error: unknown error
  [0-0] 2020-06-04T18:24:54.004Z WARN webdriver: Request failed with status 500 due to An unknown server-side error occurred while processing the command. Original error: end of central directory record signature not found
  [0-0] 2020-06-04T18:24:54.005Z INFO webdriver: Retrying 2/3
  [0-0] 2020-06-04T18:24:54.014Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
  [0-0] 2020-06-04T18:24:54.014Z INFO webdriver: DATA {
    capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
    desiredCapabilities: {}
  }
  [0-0] 2020-06-04T18:24:54.030Z ERROR webdriver: RequestError: socket hang up
      at ClientRequest.&lt;anonymous&gt; (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/got/dist/source/core/index.js:817:25)
      at Object.onceWrapper (events.js:417:26)
      at ClientRequest.emit (events.js:322:22)
      at ClientRequest.EventEmitter.emit (domain.js:482:12)
      at ClientRequest.origin.emit (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
      at Socket.socketOnEnd (_http_client.js:453:9)
      at Socket.emit (events.js:322:22)
      at Socket.EventEmitter.emit (domain.js:482:12)
      at endReadableNT (_stream_readable.js:1187:12)
      at connResetException (internal/errors.js:608:14)
      at Socket.socketOnEnd (_http_client.js:453:23)
      at Socket.emit (events.js:322:22)
      at Socket.EventEmitter.emit (domain.js:482:12)
      at endReadableNT (_stream_readable.js:1187:12)
      at processTicksAndRejections (internal/process/task_queues.js:84:21)
  [0-0] 2020-06-04T18:24:54.031Z ERROR @wdio/runner: Error: Failed to create session.
  socket hang up
      at startWebDriverSession (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/webdriver/build/utils.js:45:11)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
  [0-0]  Error:  Failed to create session.
  socket hang up
  2020-06-04T18:24:54.147Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
  [0-0] FAILED in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
  2020-06-04T18:24:54.148Z INFO @wdio/cli:launcher: Run onComplete hook
  
  Spec Files:  0 passed, 1 failed, 1 total (100% completed) in 00:01:34 
  
  2020-06-04T18:24:54.164Z INFO @wdio/local-runner: Shutting down spawned worker
  2020-06-04T18:24:54.416Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
  2020-06-04T18:24:54.417Z INFO @wdio/local-runner: shutting down
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! e2e-cucumber-wdio-appium@1.0.0 only-one-test-aws: `npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the e2e-cucumber-wdio-appium@1.0.0 only-one-test-aws script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/device-farm/.npm/_logs/2020-06-04T18_24_54_506Z-debug.log
  
  [DEVICEFARM] ########### Entering phase post_test ###########
  
  
  [DEVICEFARM] ########### Finish executing testspec ###########
  
  [DEVICEFARM] ########### Setting upload permissions ###########
  
  
  [DEVICEFARM] Tearing down your device. Your tests report will come shortly.
  
  </code></pre>
  
  <p>I also tried this <a href="https://stackoverflow.com/questions/61642870/aws-device-farm-react-native-appium-nodejs-webdriverio-tests-not-working">question's solution</a> by installing the <code>webdriverio</code> and <code>@wdio/cli</code> dependencies globally, though it did not work to me.</p>
  
  <p>PS: I've already been able to successfully perform tests on the AWS Device Farm using webdriverio and cucumber. Though, these errors started to show up for me recently and I still have no clue on how to solve them.</p>
  
  <p>Can someone please help me with this?</p>