title: Calabash tests are often stuck on starting server if being executed over Wi-fi
body: <h2>General description of a problem:</h2>
  
  <p>Because of project specific (<em>iDevice has to be connected to the external hardware via Lightning port</em>) we have to execute our pack of tests over Wi-fi. </p>
  
  <p>There is dedicated Macbook Pro(early 2011) with Yosemite 10.10.2 working as a client for tests execution. Both Mac and iDevice are connected to the same isolated (<em>1 Mac and 1 iDevice only</em>) Wi-Fi access point (<em>without access to the internet</em>).</p>
  
  <p>Each time I'm trying to execute all the suite of existing tests (~150 tests) I'm facing the fact that at some random point <strong><em>(i.e. some tests have already been executed by that time</em></strong>) the application with Calabash server is launched visually on iDevice-side but from command line perspective the server seem to not respond to the Mac-client that it has launched successfully (just my assumption) and the whole execution just gets stuck at this point. If I drop tests execution  via "Ctrl+C" and try to start the execution again or execute start_test_server_in_background via console I'll see that the application server is started and closed immediately for number of times without any luck to establish new stable application server. </p>
  
  <p>The only workaround here is to reboot the iDevice and to launch the App server after reboot with iDevice connected via USB and only then I'll be able to run Calabash tests over Wi-fi again.</p>
  
  <p>I've tried to play with many different iDevices and different Wi-Fi access points, and several Mac's as well, but with no luck to have a single solid unbroken run for all tests. </p>
  
  <p>Would be veeeerry glad if someone helps me resolve this incredibly annoying issue.</p>
  
  <h2>Some details:</h2>
  
  <ul>
  <li>iOS version: 8.1.3, 8.2</li>
  <li>XCode version: 6.2</li>
  <li>Mac OS version: 10.10.2</li>
  <li>Xcode path: /Applications/Xcode.app/Contents/Developer</li>
  <li>Calabash version: 0.13.0 (and 0.14.0)</li>
  <li>calabash.framework version: 0.13.0 (and 0.14.0)</li>
  <li>Here's the console output (with DEBUG=1) when the 'hang' occurs:</li>
  </ul>
  
  
  
  <pre><code>@test
  Scenario: [12657] Scenario Name # features/2_feature_name.feature:87
  
  INFO: Using uia strategy: 'host'
  Preparation took 0.099263 seconds
  {
                          :app =&gt; "com.xxx.one",
                         :args =&gt; [],
      :bundle_dir_or_bundle_id =&gt; "com.xxx.one",
                    :bundle_id =&gt; "com.xxx.one",
                       :device =&gt; "com.xxx.one",
                :device_target =&gt; "00fea94be88909c74aa7b68a2b7f3f339407163b",
                :launch_method =&gt; :instruments,
               :launch_retries =&gt; 5,
                     :log_file =&gt; "/var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/run_loop.out",
                    :no_launch =&gt; false,
                      :no_stop =&gt; false,
                        :reset =&gt; false,
                  :results_dir =&gt; "/var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1",
            :results_dir_trace =&gt; "/var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/trace",
                       :script =&gt; "/var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/_run_loop.js",
                  :sdk_version =&gt; nil,
                         :udid =&gt; "00fea94be88909c74aa7b68a2b7f3f339407163b",
                 :uia_strategy =&gt; :host,
                        :xcode =&gt; "6.2",
                   :xcode_path =&gt; "/Applications/Xcode.app/Contents/Developer"
  }
  
  ### Starting on 00fea94be88909c74aa7b68a2b7f3f339407163b App: com.xxx.one ###
  2015-04-08 12:38:22 +0300 xcrun instruments -w 00fea94be88909c74aa7b68a2b7f3f339407163b -D /var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/trace -t Automation com.dxo.one -e UIARESULTSPATH /var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1 -e UIASCRIPT /var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/_run_loop.js &gt;&amp; /var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150408-59711-1rjd4d1/run_loop.out 
  </code></pre>
  
  <p><strong>UPDATE:</strong> Here's what the Calabash prints out to the terminal when it's impossible for it to relaunch the application after it gets stuck:</p>
  
  <pre><code>    Calabash::Cucumber::Launcher::StartError: Time out waiting for UIAutomation run-loop Error while writing to fifo. RunLoop::Fifo::NoReaderConfiguredError. 
        Logfile /var/folders/4w/tw3_yvd54sq9brl1kxf9cy8c0000gp/T/run_loop20150422-35789-1mgrom1/run_loop.out 
  
        2015-04-22 11:03:41.649 instruments[35913:114217] WebKit Threading Violation - initial use of WebKit from a secondary thread.
       Instruments Trace Error : Target failed to run: Failed looking up pid of launched process
  
        (Calabash::Cucumber::Launcher::StartError)
       /Users/wrathttodd/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/calabash-cucumber-0.14.0/lib/calabash-cucumber/launcher.rb:772:in `new_run_loop'
       /Users/wrathttodd/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/calabash-cucumber-0.14.0/lib/calabash-cucumber/launcher.rb:630:in `relaunch'
       /Users/wrathttodd/APP NAME/PATH/AAT/features/support/01_launch.rb:27:in `Before'
  </code></pre>