Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
111.83k stars 10.7k forks source link

Unable to connect over TCP/IP #2889

Open Strykar opened 2 years ago

Strykar commented 2 years ago

Environment

dependencies:

Describe the bug Unable to connect over TCP/IP, lan WIFI in this case

On errors, please provide the output of the console (and adb logcat if relevant).

$ scrcpy --tcpip=192.168.1.11:41521
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
WARN: Could not disable minimize on focus loss
failed to connect to '192.168.1.11:41521': Connection refused
ERROR: Could not connect to 192.168.1.11:41521
ERROR: Server connection failed

$ nmap -p 41521 192.168.1.11
Starting Nmap 7.92 ( https://nmap.org ) at 2021-12-18 19:20 IST
Nmap scan report for ap (192.168.1.11)
Host is up (0.030s latency).

PORT      STATE SERVICE
41521/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds

$ ping -c 3 192.168.1.11
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=64 time=5.87 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=64 time=1.28 ms
64 bytes from 192.168.1.11: icmp_seq=3 ttl=64 time=1.57 ms

--- 192.168.1.11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.275/2.904/5.870/2.100 ms

USB and Wireless debugging are both enabled - https://i.imgur.com/A3RqPPh.jpg

rom1v commented 2 years ago

What is the result of:

adb connect 192.168.1.11

?

https://github.com/Genymobile/scrcpy#tcpip-wireless

Strykar commented 2 years ago
$ adb connect 192.168.1.11
failed to connect to '192.168.1.11:5555': Connection refused

$ adb connect 192.168.1.11:41521
* daemon not running; starting now at tcp:5037
* daemon started successfully
failed to connect to 192.168.1.11:41521

FWIW, the port under Wireless ADB changes every time I back out of that menu, so tests were done while those options were displayed on the phone. How do I troubleshoot this?

rom1v commented 2 years ago

Note that --tcpip automates the TCP/IP connection with adb tcpip and adb connect, the method which is supported since forever and requires to initially connect the device over USB: https://developer.android.com/studio/command-line/adb.html#wireless

Android 11 added another mechanism to avoid the initial connection over USB, but requires some pairing steps. These pairing steps are not automated by --tcpip, so if you want to use that, you must manually pair your device first: https://developer.android.com/studio/command-line/adb.html#connect-to-a-device-over-wi-fi-android-11+

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

Just updated ethernally script which facilitates wireless mirroring https://github.com/fusionneur/ethernally

Let me know if you encounter any issue. Thank you