Post by PaulBut you know, in the end, there is a proper way to do this.
SOLVED!
<https://i.postimg.cc/Dz1rcpDX/scrcpy26.jpg> The port is locked up
<https://i.postimg.cc/25XrGW9R/scrcpy27.jpg> But it's not in the list
<
Loading Image...> Android assigns the port
<
Loading Image...> Apparently HNS solved it
I'm confused.
So all I can tell you is what happened.
The problem solved itself immediately after I ran the HNS commands cited
in one of the references (I think it was the 12 year old stackexchange).
<https://i.postimg.cc/pdyTjwnT/scrcpy28.jpg>
Thanks for your help - in the end - the problem "went away" the moment I
ran this command - but I do not know why the problem "was there" in the
first place - but now - when it comes back - and it will - I'll run this
command again. :)
C:\> net stop hns && net start hns
C:\> adb connect 192.168.1.4:44285
C:\> netstat -ano | findstr 44285
TCP 192.168.1.198:1708 192.168.1.4:44285 ESTABLISHED 8172
Post by Paul(You must use a modern browser, to view the simple text content on these pages.)
https://github.com/Genymobile/scrcpy/blob/master/doc/connection.md
scrcpy --tcpip=192.168.1.1 # default port is 5555
scrcpy --tcpip=192.168.1.1:5555
This is confusing to me - even though I use this stuff every day.
I used to use these terms "--tcpip" many years ago - but no longer.
After Android+adb+scrcpy went to Wi-Fi, I no longer use the USB cable.
However...
I don't profess to understand all this tcp port stuff so I have to be
careful what I say as I don't know how much of that "tcpip" stuff matters.
Suffice to say Android adb on Windows can connect to the phone via
either USB or Wi-Fi but we used to _also_ use those tcpip options after
initially connecting via USB and _then_ pulling the cable out to go Wi-Fi.
Andy Burns will know more about this than I do, but that's how we did it.
a. Either we stayed on USB
b. Or we _started_ on USB (and then went Wi-Fi using tcpip port 5555)
<
Loading Image...>
c. Or we stayed on Wi-Fi (and used the port that Android tells us to use)
As you can see from the screenshot, the port is assigned to us.
I don't get to pick the port and it changes on every Wi-Fi connection.
<https://i.postimg.cc/pdyTjwnT/scrcpy28.jpg>
Those randomly assigned ports are usually from 3xxxx to 4xxxx (not 5555).
Post by PaulIf adb TCP/IP mode is disabled on the device (or if you don't know the IP address),
scrcpy --tcpip # without arguments
It will automatically find the device IP address and adb port,
enable TCP/IP mode if necessary, then connect to the device before starting.
https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
5555 Unofficial Wireless adb (Android Debug Bridge) control of an Android device over the network.
And that port is actually used by more than one service.
*******
"Documentation for control protocol #673"
https://github.com/Genymobile/scrcpy/issues/673
"The protocol between the client and the server is internal
and private, and may (and will) change at any time.
Recently, as you noticed, the communication has changed
to use 2 sockets in order to support copy-paste (ec71a3f).
"
https://github.com/Genymobile/scrcpy/commit/ec71a3f66ab48c2fdd1728753acc09edbd4db570
"Use two sockets for video and control
The socket used the device-to-computer direction to stream the video and
the computer-to-device direction to send control events.
Some features, like copy-paste from device to computer, require to send
non-video data from the device to the computer.
- one for streaming the video from the device to the client;
- one for control/events in both directions.
"
In this thread, without explanation, their firewall has 5555,7007 open.
https://stackoverflow.com/questions/66611227/afwall-firewall-unblock-adb-wireless
And 7007 isn't in the Wiki port list.
All this is what we _used_ to do years ago _before_ Android had the
capability of connected to Windows adb _without_ using the USB cable.
You can tell because of the "5555" port number.
Nowadays, we use a port number assigned to us from 30000 to 40000
(note the extra digit!) which the phone randomly provides us.
When it's all working, here's how we do the connection nowadays:
On the phone we connect to Wi-Fi & the LAN & get our random port.
1. We make sure our Android Wi-Fi is on & connected to the LAN
2. We longpress the handy "Wireless Debugging" swipe-down tile
3. This tells us the random port that we are assigned today
(today that random port is 44285)
On the PC we open up a command window & start adb & connect to Android
1. C:\> adb devices
2. C:\> adb connect 192.186.1.4:44285
3. C:\> scrcpy -s 192.168.1.4
I admit I'm confused for a couple of reasons though.
a. First off, this works 99% of the time; but 1% of the time I get
the error which started this thread in the first place. Dunno why.
b. I sometimes do see port 55555 (note the extra digit) showing up!
<https://i.postimg.cc/Hs1ZZ5H0/scrcpy29.jpg>
b. I usually do NOT see port 55555; I see the random port instead.
(see the same screenshot, different session).
Note: I had just killed the second session so that's why it's closed.
The good news?
This single Windows command solved the connection problem!
C:\> net stop hns && net start hns
Running that single command _instantly_ solved the connection problem!
The bad news?
I don't know why it happened & I don't even know why it worked.
I'm confused.
But... it's working again.