TestProject Forum

Not able to view / mirror the Android Emulator if it is running on Cloud VM

This is my Agent Setup:

  • Running a Headless Android Emulator in the Azure Linux VM
  • Running a Headless Agent in the same VM.

To register the agent with Testproject.io, i ran this command and it get registered successfully.

./testproject-agent register -a agantName -t API_KEY

Now if try to mirror the Emulator screen from Testproject.io agent page,It’s failing with following error:

Couldn't connect to agent of device (emulator-5554)

Only screen mirroring is not working. But I’m able to run test cases without any issues. Even I’m able to see screen shots for failed test cases from TP’s website.

To confirm this issue is not related to VM,I did the same setup on my Local Laptop, I’m able to view the Emulator Screen without any issue.

Can you help me on why its not working when comes to VM?

The reason it is working on your laptop is that the local agent and both the virtual agent and emulator are all on the same LAN. Either using a virtual switch or through your actual switch/router using the same VLAN.
This does not apply when you use a remote VM on Azure, as the virtual headless agent and headless emulator are on the same LAN, but your local agent is on a different LAN.
To overcome this issue please try to set up a VPN on both your VM on Azure and on your local machine where you are trying to mirror from.

Currently, to mirror the device remotely both agents must be on the same LAN.
In your case, it’s not happening please take a look at this chart:

I hope it is more clear now why it’s not working for you,
Let me know if you were able to set up a VPN and if it solved your issue.

Thanks for your information.
Yes, VPN will work. But it will be little difficult to setup.

I found another solution with help of SOCKS Proxy and SSH Tunneling.

Steps to Connect:

  1. Create a SSH tunneling to remote agent server by running this command:
    ssh -D 8123 -q -N -i PRIVATE_KEY.pem USERNAME@SERVER_IP
  2. Set your Bowser’s Proxy Settings to Manual Proxy and configure following things:
  • Set SOCKS Host to localhost
  • Set SOCKS Port to 8123
  • Set SOCKS version to v5

Now you should able to view the Emulator Screen from your Local Browser.