calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Could not connect to the DeviceAgent service #1233

Open andrelugomes opened 7 years ago

andrelugomes commented 7 years ago

XCode Version 8.1 (8B62) MacOS 10.12.1 (16B2555) SIERRA Calabash sandbox version: 0.1.18

Bundle updated!

Done! Now the sandbox contains: calabash-ios: 0.20.3 calabash-android: 0.8.4 xamarin-test-cloud: 2.1.0

Verifying Calabash : curl -v http://192.168.153.86:37265/version

*   Trying 192.168.153.86...
* Connected to 192.168.153.86 (192.168.153.86) port 37265 (#0)
> GET /version HTTP/1.1
> Host: 192.168.153.86:37265
> User-Agent: curl/7.49.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 664
< Access-Control-Allow-Credentials: true
< Date: Wed, 30 Nov 2016 15:48:24 GMT
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
< Accept-Ranges: bytes
< Access-Control-Max-Age: 3000
< 
* Connection #0 to host 192.168.153.86 left intact
{"outcome":"SUCCESS","ios_version":"10.1.1","app_id":"br.com.app","app_name":"","app_base_sdk":"iphoneos10.1","git":{"remote_origin":"git@github.com:calabash\/calabash-ios-server.git","branch":"master","revision":"5ec0a54"},"iOS_version":"10.1.1","simulator_device":"","version":"0.20.3","server_port":37265,"model_identifier":"iPhone5,1","form_factor":"iphone 4in","app_version":"1","simulator":"","4inch":true,"iphone_app_emulated_on_ipad":false,"device_family":"iPhone","screen_dimensions":{"scale":2,"width":640,"native_scale":2,"sample":1,"height":1136},"short_version_string":"1.0","system":"iPhone5,1","device_name":"iPhone5"}

Running Console:

DEVICE_TARGET=5761d66c6391a1cb240b7d2fbc46983c2b51bf30 BUNDLE_ID="br.com.app" DEVICE_ENDPOINT=http://192.168.153.86:37265 CODE_SIGN_IDENTITY="iPhone Developer: Gustavo (56DPDH86LP)" DEBUG=1 bundle exec calabash-ios console
Running irb...

#########################  Useful Methods  ##########################
     ids => List all the visible accessibility ids.
  labels => List all the visible accessibility labels.
    text => List all the visible texts.
   marks => List all the visible marks.
    tree => The app's visible view hierarchy.
   flash => flash(<query>); Disco effect for views matching <query>
 verbose => Turn debug logging on.
   quiet => Turn debug logging off.
    copy => Copy console commands to clipboard.
   clear => Clear the console.

Calabash says, "I'm gonna take this to 11."
DEBUG: Trying to connect to Calabash Server: 1 of 1
DEBUG: Connected to Calabash Server on try: 1 of 1
EXEC: xcrun simctl list devices --json
EXEC: xcrun instruments -s devices
Attached to: #<Launcher: DeviceAgent/ios_device_manager>

Starting Server test

calabash-ios 0.20.3> start_test_server_in_background

DEBUG: HTTP: get http://192.168.153.86:27753/1.0/health {:retries=>1, :timeout=>0.5}
DEBUG: DeviceAgent-Runner is not running
DEBUG: HTTP: get http://192.168.153.86:27753/1.0/health {:retries=>1, :timeout=>0.5}
DEBUG: Waiting for DeviceAgent to launch...
EXEC: /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager install --device-id 5761d66c6391a1cb240b7d2fbc46983c2b51bf30 --app-bundle /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app --codesign-identity iPhone Developer: Gustavo Folsta (56DPDH86LP)
DEBUG: Took 16.201475 seconds to install DeviceAgent
EXEC: /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager start_test --device-id 5761d66c6391a1cb240b7d2fbc46983c2b51bf30 >& /Users/entelgy/.run-loop/xcuitest/ios-device-manager.log
DEBUG: HTTP: get http://192.168.153.86:27753/1.0/health {:retries=>900, :timeout=>90.0}
RuntimeError: 

Could not connect to the DeviceAgent service.

device: #<Device: iPhone5 (10.1.1) 5761d66c6391a1cb240b7d2fbc46983c2b51bf30>
   url: http://192.168.153.86:27753/

To diagnose the problem tail the launcher log file:

$ tail -1000 -F /Users/entelgy/.run-loop/xcuitest/ios-device-manager.log

    from /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:1244:in `rescue in launch_cbx_runner'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:1235:in `launch_cbx_runner'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:264:in `launch'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:140:in `run'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/run_loop-2.2.2/lib/run_loop.rb:113:in `run'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:408:in `block in new_run_loop'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:406:in `times'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:406:in `new_run_loop'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:365:in `relaunch'
    from /Users/entelgy/.calabash/sandbox/Gems/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/core.rb:1567:in `start_test_server_in_background'
    from (irb):1
    from /Users/entelgy/.calabash/sandbox/Rubies/2.1.6-p336/bin/irb:11:in `<main>'
calabash-ios 0.20.3> 
andrelugomes commented 7 years ago
2016-11-30 13:52:40.682 iOSDeviceManager[7950:129941] Creating the test bundle connection.
2016-11-30 13:52:40.683 iOSDeviceManager[7950:129941] Listening for proxy connection request from the test bundle (all platforms)
2016-11-30 13:52:40.683 iOSDeviceManager[7950:129941] Resuming the test bundle connection.
2016-11-30 13:52:40.683 iOSDeviceManager[7950:129753] Checking test manager availability...
2016-11-30 13:52:40.683 iOSDeviceManager[7950:129753] Starting test session with ID AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
2016-11-30 13:52:40.720 iOSDeviceManager[7950:129807] testmanagerd handled session request using protcol version 22.
2016-11-30 13:52:41.410 iOSDeviceManager[7950:129808] Disconnected from test manager daemon socket
2016-11-30 13:52:41.411 iOSDeviceManager[7950:129753] Bundle Connection Disconnected in state 'connecting'
2016-11-30 13:52:41.515 iOSDeviceManager[7950:129753] Test Completed with Result: Bundle Connection Failed in error: Error Domain=com.facebook.XCTestBootstrap Code=4 "Lost connection to test process with state 'connecting'" UserInfo={NSLocalizedDescription=Lost connection to test process with state 'connecting'}
2016-11-30 13:52:41.515 iOSDeviceManager[7950:129753] Err: Error Domain=com.facebook.XCTestBootstrap Code=0 "Test Manager Connection Failed: Internal Error Error Domain=com.facebook.XCTestBootstrap Code=4 "Lost connection to test process with state 'connecting'" UserInfo={NSLocalizedDescription=Lost connection to test process with state 'connecting'}" UserInfo={NSLocalizedDescription=Test Manager Connection Failed: Internal Error Error Domain=com.facebook.XCTestBootstrap Code=4 "Lost connection to test process with state 'connecting'" UserInfo={NSLocalizedDescription=Lost connection to test process with state 'connecting'}, NSUnderlyingError=0x7fdd5b3c45e0 {Error Domain=com.facebook.XCTestBootstrap Code=4 "Lost connection to test process with state 'connecting'" UserInfo={NSLocalizedDescription=Lost connection to test process with state 'connecting'}}}
jmoody commented 7 years ago

Can you open the DeviceAgent app manually or does it crash on launch?

Is there anything in your device logs that indicates the DeviceAgent has crashed?

andrelugomes commented 7 years ago

DeviceAgent open and still opened with a Black screem

wwlacy6 commented 7 years ago

@andrelugomes I had a similar issue, and fixed it by ensuring that the phone and laptop were on the same wifi network. Maybe this will work for you as well.

jaysacco commented 7 years ago

I had the same issue running the tests on a mac to a simulator on the same mac. Everything was working fine until one day it wasn't and I got the error. The issue was caused by the mac (which was using DHCP) getting a new IP address. My test launch script was still specifying the old IP address with the DEVICE_ENDPOINT parameter. Once I updated the DEVICE_ENDPOINT IP address the problem was solved.

andrelugomes commented 7 years ago

@jaysacco I will try. Thantk

ghvg1313 commented 7 years ago

I'm getting the exact same issue, my mac and iPhone are under the same network, everytime I run start_test_server_in_background or cucumber, DeviceAgent will open and quit in a flash and then no response after that, the console just keep waiting for the health check from DeviceAgent.

jakubbloksa commented 7 years ago

I am getting the same error, too. I am running iPad simulator on my Mac, therefore they should be on the same network. I tried to pass DEVICE_ENDPOINT IP to cucumber command, but with no effect. @jaysacco how to update DEVICE_ENDPOINT IP properly pls?

jaysacco commented 7 years ago

For the simulator, use the ip address of the mac the simulator is running on: DEVICE_ENDPOINT=http://"ip address of mac":37265 e.g. DEVICE_ENDPOINT=http://10.8.8.243:37265

saipawan999 commented 7 years ago

I am facing the same issue even if i have same ip for simulator and mac.

jmoody commented 7 years ago

If you are targeting a simulator, there should be no need to set the DEVICE_ENDPOINT - it will default to http://127.0.0.1:37265. If you are having problems connecting to simulators, you could try http://localhost:37265.

I want to make sure that no one in this thread is use Xcode 8.3 beta - it is not supported yet.

It is possible that the simulator is in a bad state. Try:

$ bundle exec run-loop simctl manage-processes

You can also try rebooting the machine.

You can watch the simulator logs using:

$ bundle exec run-loop simctl tail

^ that will tell you more information about what is going wrong.

saipawan999 commented 7 years ago

Still i am getting the below error

Could not connect to the DeviceAgent service.

device: #<Simulator: iPhone 6s (10.0) 8B279B5B-E70A-4080-94EC-A7FB62940717 x86_64> url: http://127.0.0.1:27753/

To diagnose the problem tail the launcher log file:

$ tail -1000 -F /Users/pawan.lingutla/.calabash/iOSDeviceManager/logs/current.log

from /Library/Ruby/Gems/2.0.0/gems/run_loop-2.3.1/lib/run_loop/device_agent/client.rb:1305:in `rescue in launch_cbx_runner'
jaysacco commented 7 years ago

27753 may be the wrong port number. On my system it's 37265. Using 127.0.0.1 didn't work for me. When using the simulator, I set DeviceAgent as noted in my previous post above and it works.

jmoody commented 7 years ago

port 27753

This is the DeviceAgent port. It is an application running on the simulator or device.

port 37265

This is the LPServer port - it is an embedded HTTP server inside your application.

from /Library/Ruby/Gems/2.0.0/gems/run_loop-2.3.1/lib/run_loop/device_agent/client.rb:1305:in `rescue in launch_cbx_runner'

You are using Apple's system ruby which is not supported.

https://github.com/calabash/calabash-ios/wiki/Ruby-on-MacOS

We recommend that use rbenv.

umara123 commented 7 years ago

I'm getting the same issue - pretty much exactly as ghvg1313 described, except I'm using a Simulator.

macOS Sierra 10.12.4 Xcode 8.2.1

calabash-cucumber 0.20.4 run_loop 2.4.1

iPhone 6s Simulator, 9.1 iPhone 6s Simulator, 10.2

In one test run consisting of multiple feature files, each with multiple scenarios, usually the first scenario passes without any problems, then the second scenario fails with the error mentioned above Could not connect to the DeviceAgent service..... Following this scenarios randomly pass/fail due to this error.

This issue is preventing me running any tests at all on iOS 10.x, my current stable setup is still on El Capitan with Xcode 7.3

umara123 commented 7 years ago

@jmoody Any thoughts? I've noticed this issue has been open for a while and there have been multiple releases (of run loop and calabash) since then.

umara123 commented 7 years ago

For anyone else having the same issue, @jmoody 's suggested fix here - https://github.com/calabash/run_loop/issues/618#issuecomment-295177927 has helped solve the issue for me.

I've added another sleep at the end.

fancychimp commented 7 years ago

What about for real devices....?

sivaramprasadc commented 7 years ago

Getting the same error with the below configuration: OSX: Sierra 10.12.5 ruby 2.4.1 run_loop 2.4.1 xcode 8.2.1 Both Machine and real device are on same network Provided DEVICE_TARGET, DEVICE_ENDPOINT, BUNDLE_ID parms. From last 2 days we are receiving the error message: [‎7/‎5/‎2017 10:18 PM] Michael Hunter: RuntimeError: Could not connect to the DeviceAgent service. device: #<Device: iPod touch (9.3.5) a6d7fffa06404f5c782cf2bb7538f5667bf54276> url: http://10.1.10.24:27753/ To diagnose the problem tail the launcher log file: $ tail -1000 -F /Users/automationtesting/.calabash/iOSDeviceManager/logs/current.log

Please suggest resolution. Thanks in advance.

cmdshepard commented 7 years ago

I'm experiencing the same problem while trying to run on a real iOS device - No errors in the log last line is

/usr/bin/xcrun codesign -d --entitlements :- /Users/hydrafox/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/run_loop-2.5.4/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app
jmoody commented 7 years ago

Please trying running that command and reporting the output.

$ /usr/bin/xcrun codesign -d --entitlements :- /Users/hydrafox/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/run_loop-2.5.4/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app
catfishuang commented 6 years ago

why can not connect to deviceagent ......

calabash-ios 0.21.6 run_loop 3.0.0 macos 10.13.6 ruby 2.3.4p301 xcode 9.3.1

curl http://172.22.76.188:27753/1.0/health
-- timeout

safari of iphone7, visit http://localhost:27753/1.0/health
-- return {"status":"calash is ready and waitng" }

curl http://172.22.76.188:37265/version {"device_family":"iPhone","outcome":"SUCCESS","server_port":37265,"simulator":"","app_name":"大众点评","app_version":"10.5.0","screen_dimensions":{"height":1334,"bounds":{"y":0,"x":0,"width":375,"height":667},"sample":1,"native_bounds":{"y":0,"x":0,"width":750,"height":1334},"width":750,"native_scale":2,"bounds_portrait_height":667,"bounds_portrait_width":375,"scale":2},"git":{"revision":"988abad","remote_origin":"git@github.com:calabash\/calabash-ios-server.git","branch":"tag\/0.21.6"},"device_name":"iPhone 7","4inch":false,"app_id":"com.dianping.dpscope","form_factor":"iphone 6","version":"0.21.6","server_identifier_to_skip":"","short_version_string":"10.5.0","server_identifier":"988abadaed90380c41da4d36aab1f08d0e217879","build_date":"2018-24-05 08:17:17 +0200","ios_version":"10.0.1","iphone_app_emulated_on_ipad":false,"model_identifier":"iPhone9,1","app_base_sdk":"iphoneos11.3"}