appium-device-farm icon indicating copy to clipboard operation
appium-device-farm copied to clipboard

Error: connect ETIMEDOUT

Open ValzRon opened this issue 2 years ago • 6 comments

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!

ValzRon avatar Nov 23 '23 13:11 ValzRon

@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 avatar Nov 23 '23 14:11 saikrishna321

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

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

saikrishna321 avatar Nov 23 '23 15:11 saikrishna321

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 avatar Nov 23 '23 15:11 ValzRon

@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.

ValzRon avatar Nov 23 '23 16:11 ValzRon

@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 avatar Nov 24 '23 01:11 saikrishna321

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

saikrishna321 avatar Nov 24 '23 08:11 saikrishna321