scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Remote Access through vpn server-> adb device [offline]?

Open alan0048 opened this issue 2 years ago • 5 comments

  • [x] I have read the FAQ.
  • [x] I have searched in existing issues.

Environment

  • OS: [Windows 10 64-bit]
  • scrcpy version: [2.0 win_x64]
  • installation method: [Windows release, cmd]
  • device model: Nvidia Shield Pro
  • Android version: [Android TV]

Using the command line "scrcpy -m800 -b2M --no-audio" I am able to mirror my Nvidia Shield Pro through my computer while I'm on the same LAN. When away from home, I can usually connect to my local lan through a Wireguard Server. Hence, I thought I'd be able to connect as usual but my adb device only shows offline?

Why isn't it working? Is there a way to get around that? Computer A --> Internet ---> Wireguard Server ---> Router (Computer B) ---> Nvidia Shield Pro [offline]

alan0048 avatar Mar 21 '23 12:03 alan0048

You can adb connect only one adb client per device.

You might be interested in this page: https://github.com/Genymobile/scrcpy/blob/master/doc/tunnels.md

rom1v avatar Mar 21 '23 13:03 rom1v

I'm afraid I didn't get that working. I will try again soon, but I'm having a hard time following what to do.

Like this: "Suppose that this server is accessible at 192.168.1.2. Then, from another terminal, run scrcpy:"

From another terminal on the same computer? Or a different?

edit: Had to revoke all access on my Shield and start over again. List of devices had dissapeared but is now solved.

alan0048 avatar Mar 21 '23 13:03 alan0048

Like this: "Suppose that this server is accessible at 192.168.1.2. Then, from another terminal, run scrcpy:"

From another terminal on the same computer? Or a different?

On the remote computer (where your Android device is plugged/connected), you execute:

adb kill-server
adb -a nodaemon server start
# keep this open

On your local computer (where you want to run scrcpy), you execute:

# in bash
export ADB_SERVER_SOCKET=tcp:192.168.1.2:5037
scrcpy --tunnel-host=192.168.1.2

192.168.1.2 is the address of the remote computer as seen from the local computer.

rom1v avatar Mar 21 '23 15:03 rom1v

Does this mean that the remote computer has to be turned on at all time in order to access the Android device remotley? I thought you could connect to the Android device solemnly from an outside network, that's what I was hoping to achieve.

Scenario 1: Computer A --> (Router A / Local LAN) --> Nvidia Shield / 192.168.10.XXX

Scenario 2: Computer A --> (Router B / Internet) --> VPN Adress --> (Router A / Local LAN) --> Nvidia Shield / 192.168.10.XXX

Can this be achieved?

alan0048 avatar Mar 25 '23 23:03 alan0048

Does this mean that the remote computer has to be turned on at all time in order to access the Android device remotley?

Yes, you communicate with the device via the computer where it is connected, not directly.

rom1v avatar Mar 27 '23 02:03 rom1v

@alan0048 I have found that only one PC can have an active adb connection to the same device. If your remote pc is the 2nd device connecting it might connect but show offline. Before leaving the house make sure to run 'adb disconnect 192.168.10.XXX' (this will disconnect the one device) on the computer that is currently connected to your Nvidia Shield. IF your laptop is the one connected at your house and then attempting to connect via VPN you may need to reboot the Nvidia Shield to stop the adb session on the Nvidia Shield.

I was able to just achieve the reverse of your Scenario 2 with an Android 7 device in my office. It VPN'ed into the office and I connected to it. Then a coworker VPN'ed into the office and connected to the Android 7 device across both VPNs. However I had to 'adb disconnect' from it before my coworker was able connect.

My Scenario 1: Remote Android A --> (Router B/ Internet) --> VPN Address --> (Router A / Local LAN ) <-- Computer A

My Scenario 2: Remote Android A --> (Router B/ Internet) --> VPN Address --> (Router A / Local LAN ) <-- VPN Address <-- (Router C/ Internet) Remote Computer 2

michaelk-realityi avatar Nov 08 '23 17:11 michaelk-realityi

I have found that only one PC can have an active adb connection to the same device.

Yes, this is an adb server limitation.

rom1v avatar Nov 08 '23 18:11 rom1v