shamanec / GADS

Simple device farm for remote control of devices and Appium test execution on iOS/Android
MIT License
47 stars 10 forks source link

Is a provider necessary? #92

Closed ZhiPeng-1997 closed 2 months ago

ZhiPeng-1997 commented 2 months ago

sorry first, i don't know the whole project well. but i have a question . when i finished set-up, and follow the guidance, finally i got a issue: "Device is unavailable"

then a check this error: i found that GADS-ui send a request that url is "/device/{dev-uuid}/health" but got 404 error image

then i follow the code and found that is a reverse proxy image

I think the request should be sent to the provider, but the host is "192.168.1.12:1991"(my android mobile ip) , not the provider host (127.0.0.1:1991), so i change it, and finally it worked! image

but still got issue: i can not control the device , when i click the device screen, i got "You should navigate back to the devices list" message

Am I using it wrong? i think provider is must because the provider keep heartbeat to the mobile

thanks !

shamanec commented 2 months ago

Yes, you got that correct - the provider should be running at all times! But if you can load the device screen, just not interact with the device - I would assume something is wrong with Appium - maybe there is some dependency like Java or ANDROID_HOME env variable or something else missing that I haven't handled properly. There are a few things you can do to debug:

  1. Start the provider with the most verbose log level using the flag --log-level=debug
  2. Where you started the provider you should have a logs folder - check the provider.log file for information
  3. Also there should be a folder for the device in logs as well - inside that folder there should be some more logs, you can also check what is there as well Let me know if you manage to find out the root cause! :)
ZhiPeng-1997 commented 2 months ago

@shamanec thanks for reply. I will try according to your suggestions, and if there are any results, I will provide timely feedback!

ZhiPeng-1997 commented 2 months ago

feedback: good news, i follow your step and then i found that my "usb debugging( security setting)" option is off, when i open it, finally it worked! should we add this tips to the set-up description file?

but i still have some questions: image ↑ is that correct? and when we add a new provider , the "host" should be the mobile device ip? (because provider use nickname to get the configuration instead of config-file), but if it is device ip, how do the backend find the provider? if it is provider ip, how do provider find a device ip? Maybe I'm wrong but I think that is a logical dead-loop. Maybe I'm using it in a wrong way? image Do we need to add a provider ip attribute or report our own ip when the provider starts (by modifying mongodb data)?

anyway thanks!

shamanec commented 2 months ago

Yeah, the drawing seems kinda correct :D So the device IPs does not matter at all - it does something like this:

  1. Provider starts and listens for connected/disconnected devices
  2. When a device is detected and is not set up yet - the provider will try to set it up by assigning random free ports for video stream, Appium server and everything else needed - all these ports and info for the set up the provider keeps in memory
  3. All those ports/services are exposed on a provider endpoint - for example a video stream for a device would live on an endpoint like http://some-providerIP:10000/device/some-udid/video-stream - and everything else is exposed in a similar way.
  4. When you do any action through the web UI it first hits the GADS UI backend - that server checks the device for which you are trying to execute an action and find out to which provider it is assigned. Then it will try to call the proper endpoint on that provider server. For example if you have a provider on your network on IP 192.168.1.5(this is how you configured it) and you have a device that this provider is providing and you try to tap - it will call the UI backend, it will find that the host of the device is 192.168.1.5, then it will build the proper URL and hit it - like 192.168.1.5:10000/device/some-udid/tap. I hope this makes it a bit clearer and why you are using the provider host machine IP and not the device IP address :) Also this is part of the README for the provider ;) :D
ZhiPeng-1997 commented 2 months ago

ohh i got it, then everything is perfect! thanks for your patience! i think this issue could be closed! thanks a lot!