Discussion:
What is an adb "reverse tunnel" when connecting Windows to Android over USB?
(too old to reply)
Andrew
2024-09-23 16:13:55 UTC
Permalink
What is an adb "reverse tunnel" when connecting Win10 to Android over USB?

I use adb every day after rebooting the desktop every morning.
1. 99 out of 100 times, adb connects with no problems over USB cable.
I don't even worry about ports as it just works.
2. 1 out of 100 times adb fails forever until the PC is rebooted
There is some kind of port conflict between the PC & adb.
3. Then adb again mirrors Android on the PC monitor, keyboard, mouse, etc.
The port conflict magically disappears with a simple reboot.

Why?
Today I decided to capture the log file and noticed a "reverse tunnel".
Could not remove reverse tunnel on port 27189
I have never heard of a reverse tunnel before - so certainly I didn't do it.

Anyone here on Android/Windows newsgroups have experience with this
particular 1 out of 100 failure of adb to connect, which includes
this reverse-tunnel being attempted?

The entire log file before rebooting is shown below for details.

C:\app\editor\android\scrcpy>usb
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
C:\app\editor\android\scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 32.1 MB/s (41159 bytes in 0.001s)
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27183, retrying on 27184
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27184, retrying on 27185
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27185, retrying on 27186
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27186, retrying on 27187
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27187, retrying on 27188
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
WARN: Could not listen on port 27188, retrying on 27189
ERROR: bind: [10013] An attempt was made to access a socket in a way forbidden by its access permissions.
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb reverse --remove" returned with value 1
WARN: Could not remove reverse tunnel on port 27189
WARN: Could not listen on port 27189, retrying on 27190
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb reverse" returned with value 1
WARN: 'adb reverse' failed, fallback to 'adb forward'
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27183, retrying on 27184
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27184, retrying on 27185
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27185, retrying on 27186
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27186, retrying on 27187
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27187, retrying on 27188
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27188, retrying on 27189
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27189, retrying on 27190
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27190, retrying on 27191
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27191, retrying on 27192
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27192, retrying on 27193
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27193, retrying on 27194
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27194, retrying on 27195
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27195, retrying on 27196
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27196, retrying on 27197
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27197, retrying on 27198
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27198, retrying on 27199
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
ERROR: Could not forward any port in range 27183:27199
ERROR: Server connection failed

C:\app\editor\android\scrcpy>usb
Andrew
2024-09-23 16:50:53 UTC
Permalink
Post by Andrew
C:\app\editor\android\scrcpy>usb
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
I just realized people won't know what the "usb" command is, which is
called "usb.bat" as there is also a "wifi.bat" command for the LAN.

The usb.bat command is simply a script kindly written by Herbert Kleebauer
which contains some "showwin" magic to hide the screen-copy console.

All it does is run one line, where the rest is to hide the console.

:r C:\app\editor\android\scrcpy\usb.bat

@echo off

REM: Download screencopy onto your PC <https://scrcpy.org/>
REM: Set Android "Developer Options" "USB debugging = On"
REM: Then plug the Android phone into the USB port of Windows
REM Then run "scrcpy -s RNJK35QUAZMA" on the Win/Mac/Linux PC
REM: This will mirror Android onto your Win/Mac/Linux PC
REM: But scrcpy leaves an annoying console behind, by default

REM: The entire point of this script is to run that one command
REM: But WITHOUT leaving an empty console behind on Windows.

:: Mirror Android onto Windows w/o leaving a console window behind
cd /d "c:\app\editor\android\scrcpy"
certutil -f -decode %~f0 showwin.exe>nul

:: now we hide console window
showwin.exe 0

:: Change this line below to the unique serial number of your phone
scrcpy -s RNJK35QUAZMA

:: after scrcpy is closed we show console window again
showwin.exe 5

del showwin.exe
goto :eof

REM I have absolutely no idea what the stuff below actually does.

-----BEGIN CERTIFICATE-----
TVpgAQEAAAAEAAAA//8AAGABAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAoAAAAA4fug4AtAnNIbgBTM0hTmljZSB0byBtZWV0IHNvbWVi
b2R5IHdobyBpcyBzdGlsbCB1c2luZyBET1MsDQpidXQgdGhpcyBwcm9ncmF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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAA==
-----END CERTIFICATE-----
MummyChunk
2024-10-04 18:45:29 UTC
Permalink
Post by Andrew
What is an adb "reverse tunnel" when connecting Win10 t
Android over USB
Post by Andrew
I use adb every day after rebooting the desktop every morning
1. 99 out of 100 times, adb connects with no problems over US
cable
Post by Andrew
I don't even worry about ports as it just works
2. 1 out of 100 times adb fails forever until the PC is reboote
There is some kind of port conflict between the PC & adb
3. Then adb again mirrors Android on the PC monitor, keyboard
mouse, etc
Post by Andrew
The port conflict magically disappears with a simple reboot
Why
Today I decided to capture the log file and noticed a "revers
tunnel"
Post by Andrew
Could not remove reverse tunnel on port 2718
I have never heard of a reverse tunnel before - so certainly
didn't do it
Post by Andrew
Anyone here on Android/Windows newsgroups have experience with thi
particular 1 out of 100 failure of adb to connect, which includes
this reverse-tunnel being attempted
The entire log file before rebooting is shown below for details
C:\app\editor\android\scrcpy>us
scrcpy 1.24 https://github.com/Genymobile/scrcpy
C:\app\editor\android\scrcpy\scrcpy-server: 1 file pushed,
skipped. 32.1 MB/s (41159 bytes in 0.001s
Post by Andrew
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27183, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27184, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27185, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27186, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27187, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
WARN: Could not listen on port 27188, retrying on 2718
ERROR: bind: [10013] An attempt was made to access a socket in
way forbidden by its access permissions
Post by Andrew
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb reverse --remove" returned with value
WARN: Could not remove reverse tunnel on port 2718
WARN: Could not listen on port 27189, retrying on 2719
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb reverse" returned with value
WARN: 'adb reverse' failed, fallback to 'adb forward
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27183, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27184, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27185, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27186, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27187, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27188, retrying on 2718
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27189, retrying on 2719
adb.exe: error: device 'RNJK35QUAZMA' not foun
ERROR: "adb forward" returned with value
WARN: Could not forward port 27190, retrying on 2719
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27191, retrying on 27192
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27192, retrying on 27193
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27193, retrying on 27194
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27194, retrying on 27195
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27195, retrying on 27196
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27196, retrying on 27197
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27197, retrying on 27198
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
WARN: Could not forward port 27198, retrying on 27199
adb.exe: error: device 'RNJK35QUAZMA' not found
ERROR: "adb forward" returned with value 1
ERROR: Could not forward any port in range 27183:27199
ERROR: Server connection failed
C:\app\editor\android\scrcpy>usb
From your
description, it seems like 99 out of 100 times, adb connects without
any issues. However, the 1 out of 100 times when it fails, it could be
due to a port conflict. This conflict might be causing the reverse
tunnel to be established on port 27189, which is why you’re seeing the
error message “Could not remove reverse tunnel on port 27189.”

Ensure that port 27189 is not being used by another application on
your PC. You can use tools like netstat or Resource Monitor to check
for active connections and identify any conflicts.

You can manually remove any reverse tunnels using the command adb
reverse --remove tcp:27189 or remove all reverse tunnels with adb
reverse --remove-all.


This is a response to the post seen at:
http://www.jlaforums.com/viewtopic.php?p=674517853#674517853

Loading...