title: Appium - Timing out and Never got a response from command
body: <p>We have UI tests to be started by Jenkins using Appium, but it results with an error:</p>
  
  <blockquote>
  <pre><code>remote stacktrace: UnknownError: An unknown server-side error occurred
  while processing the command. Original error: Error getting AVD with
  retry. Original error: Condition unmet after 60063 ms. Timing out.
  </code></pre>
  </blockquote>
  
  <p>And there is no <code>emulator</code> process found when Appium's task is running.
  Also Appium's output says:</p>
  
  <blockquote>
  <pre><code>[debug] [ADB] Emulator Nexus_5X_API_26 not running
  [debug] [ADB] Trying to find Nexus_5X_API_26 emulator
  [debug] [ADB] Getting connected emulators
  [debug] [ADB] Getting connected devices...
  [debug] [ADB] 0 device(s) connected
  [debug] [ADB] 0 emulator(s) connected
  </code></pre>
  </blockquote>
  
  <p>OK, I see that device wasn't started and this is cause for the "Timeout" error.</p>
  
  <p>But why Appium can't start it?</p>
  
  <p>I'm able to get the <code>emulator</code> executable, and Jenkin's job which is starting Appium's task can see the device:</p>
  
  <blockquote>
  <pre><code>[Pipeline] sh
  + avdmanager list avd
  ...
      Name: Nexus_5X_API_26
    Device: Nexus 5X (Google)
      Path: /home/user/.android/avd/Nexus_5X_API_26.avd
    Target: Google Play (Google Inc.)
            Based on: Android 8.0 (Oreo) Tag/ABI: google_apis_playstore/x86
      Skin: 1080x1920
    Sdcard: 100 MB
  ---------
      Name: test
      Path: /home/user/.android/avd/test.avd
    Target: Google APIs (Google Inc.)
            Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
  [Pipeline] sh
  + emulator -list-avds
  Nexus_5X_API_26
  test
  </code></pre>
  </blockquote>
  
  <p>If I'm starting device manually just by running:</p>
  
  <pre><code>/android/Android/sdk/emulator/emulator -avd Nexus_5X_API_26
  </code></pre>
  
  <p>And trigger Jenkin's job after this - I have another error:</p>
  
  <blockquote>
  <pre><code>...
  [ADB] Using adb from /android/Android/sdk/platform-tools/adb
  [debug] [ADB] Trying to find Nexus_5X_API_26 emulator
  [debug] [ADB] Getting connected emulators
  [debug] [ADB] Getting connected devices...
  [debug] [ADB] 1 device(s) connected
  [debug] [ADB] 1 emulator(s) connected
  [debug] [ADB] Sending telnet command to device: avd name
  [debug] [ADB] Getting running emulator port
  [debug] [ADB] Socket connection to device created
  [debug] [UiAutomator2] Deleting UiAutomator2 session
  [debug] [BaseDriver] Event 'newSessionStarted' logged at 1542807589908 (15:39:49 GMT+0200 (EET))
  [debug] [W3C] Encountered internal error running command: Error: Error getting AVD. Original error: Never got a response from command
  [debug] [W3C]     at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:488:11)
  ...
  </code></pre>
  </blockquote>
  
  <p>Any ideas?</p>
  
  <p>Can't even google anything with the "<em>appium Never got a response from command</em>" request...</p>
  
  <p>Also, I'm not able to reproduce this issue on my workstation's laptop - all works just perfectly.</p>
  
  <p><strong>UPD</strong> Properties are:</p>
  
  <pre><code>&lt;profile&gt;
      &lt;id&gt;linux-emulator-8.0&lt;/id&gt;
      &lt;properties&gt;
          &lt;hub.url&gt;http://0.0.0.0:4723/wd/hub&lt;/hub.url&gt;
          &lt;device.name&gt;Android Emulator&lt;/device.name&gt;
          &lt;avd&gt;Nexus_5X_API_26&lt;/avd&gt;
          &lt;platform.name&gt;Android&lt;/platform.name&gt;
          &lt;platform.version&gt;8.0&lt;/platform.version&gt;
          &lt;auto.grant.permissions&gt;true&lt;/auto.grant.permissions&gt;
          &lt;full.reset&gt;true&lt;/full.reset&gt;
          &lt;no.reset&gt;false&lt;/no.reset&gt;
          &lt;app.path&gt;/home/user/project/project.apk&lt;/app.path&gt;
          &lt;app.name&gt;com.gen.workoutme&lt;/app.name&gt;
          &lt;screenshot.path&gt;
              ${project.basedir}/../screenShots/${platform.name}/${platform.version}/${device.name}/
          &lt;/screenshot.path&gt;
          &lt;automation.name&gt;UiAutomator2&lt;/automation.name&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p><strong>UPD 2</strong> Not sure how - but not it works if run <code>emulator</code> manually.
  But still, there is a problem with starting the <code>emulator</code> from Appium itself.</p>
  
  <p>Found the weird error in its log:</p>
  
  <blockquote>
  <pre><code>[ADB] [AVD OUTPUT] Fatal: QXcbConnection: Could not connect to display  ((null):0, (null))
  [ADB] [AVD OUTPUT] INFO: QtLogger.cpp:66: Fatal: QXcbConnection: Could not connect to display  ((null):0, (null))
  [ADB] Emulator avd Nexus_5X_API_26 exited with code null, signal SIGABRT
  </code></pre>
  </blockquote>
  
  <p>Can't google for reason yet but it looks like the main issue - something with a connection to the <code>$DISPLAY</code>, although it present.</p>