AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
324 stars 101 forks source link

Error: connect ETIMEDOUT #903

Open ValzRon opened 10 months ago

ValzRon commented 10 months ago

So I have somewhat of a complex setup:

Im running a Cloud Run instance with Appium and all its needed plugins and dependencies. Before the Appium server starts inside my instance I ADB connect to multiple devices (for testing purpose im trying 2 atm). The devices are NOT on the same machine so thats why i connect them explicitly: grafik As you can see in this picture, the device farm detects those adb connected devices and adds them to its list. After that a worker acting as the test agent throws a session create at the Appium server with all the necessary Espresso setup steps (force rebuild, device initialization and install espresso server). This step obviously takes time, in my case gradle alone takes up a little over 2 minutes + install of the apk etc.

Then comes the actual problem. Im performing 2 sessions on 2 devices to set them up. However, rarely do both sessions pass. In most cases 1 fails, 1 passes, sometimes both fail. I get this error: grafik

Now ive already fiddled with firewall policies but since the sessions get through sometimes, that cant be the issue. Ive also increased the following capabilities to 300 seconds to be sure:

appium:setUiautomator2ServerInstallTimeout
appium:deviceAvailabilityTimeout
appium:setNewCommandTimeout

None of these seemed to work. It also seems to be a timeout enforced by the device farm plugin. Is there some timeout I can increase to prevent this if the espresso building process takes too long?

Another observation I made is that the remote host URL 192.168.1.1:4723/wd/hub/session is set for both devices. Could that be the issue? The Appium server starts with 2 IP addresses that can be accessed from outside, yet both devices try to communicate to only one. Here is what the dashboard looks like: grafik

What even is "Device Location" ?

A lot of questions, I apologize in advance - but i've been battling this Issue for days now and appreciate any advice or input you can give me. Thanks!

saikrishna321 commented 10 months ago

@ValzRon I notice both the device locations are having same IP. This needs to be address.

  1. Are you able to access 192.168.1.1:4723/device-farm/ from the test agent ?
saikrishna321 commented 10 months ago

Can you also confirm if you are using remote-execution concept

https://appium-device-farm-eight.vercel.app/remote-execution/

ValzRon commented 10 months ago

Can you also confirm if you are using remote-execution concept

https://appium-device-farm-eight.vercel.app/remote-execution/

Im not using the Hub/Node approach, since that would require me to start multiple Cloud run instances equal to the number of emulators. These instances would also run in the same environment as the Hub instance, so they are not on the same machine as the emulators. So i didnt see any benefit other than more readable logs on each Node. I wanted to build something closer resembling a local execution with multiple device to one Appium Server. You're saying that could be the problem?

ValzRon commented 10 months ago

@ValzRon I notice both the device locations are having same IP. This needs to be address.

2. Are you able to access 192.168.1.1:4723/device-farm/ from the test agent ?

This is the request flow: [Worker/Test agent] -> HTTPS request (eg. https://my-cloudrun-service:443) -> Cloud Run load balancer -> Cloud Run instance (with port 4723 exposed) -> localhost:4723

So any requests received via port 443 will internally be forked to port 4723, and the test agent can send requests but to localhost in Cloud run.

saikrishna321 commented 10 months ago

@ValzRon can you join slack, easy to communicate

Join me on Slack -- it’s a faster, simpler way to work. Sign up here, from any device: https://join.slack.com/t/appiumtestparallel/shared_invite/zt-2tmkvgp2-QyWnT~Va4HsQD7h38G3kgQ

saikrishna321 commented 10 months ago

@ValzRon Can you share full logs and also your server configuration please