3

I can connect to my smartphone with ADB using a usb cable, I'm also able to connect over tcp/ip to the same smartphone with adb connect 192.168.1.110 while the usb cable is still connected.

But, as soon as I disconnect the cable, I loose the tcp/ip connection, the device appears to be "offline" (as result to "adb devices" command) and I cannot reconnect over network until I re-connect the cable.

My steps are (this way it works) :

  1. connect the usb cable
  2. adb kill-server
  3. adb tcpip 5555
  4. adb connect 192.168.1.110 (here it connects succesfully!)
  5. disconnect usb cable => I loose network connection to the smartphone

If after step 3 I disconnect the cable, the step 4 doesn't work (port 5555 closed)

It seems like adbd daemon is running ONLY when the cable is connected.

AS my device is not rooted I don't find any way to force adbd daemon to start without connecting the usb cable.

Any idea?

[UPDATE] I just tried to scan the smartphone for tcp port opened and I found that as soon as I run the command: adb tcpip 5555 the scanning found the port 5555 opened but as soon as I disconnect the usb cable, I run again the scan and the port 5555 is found to be closed This confirm that as soon as I disconnect the usb cable don't know why but adb stop responding on port 5555 or the daemon itself get killed or similar

[UPDATE] I just did the same steps on another Android device (an asus tablet) and it works perfectly, when I disconnect the cable, the tcp port remain opened, so the issue is not with the steps I'm following but with something else

[UPDATE] I found other posts with similar issue, this is one of them: adb connection by wifi getting killed when a new USB attached/detached , unfortunately I cannot do what he says as my smartphone is not rooted and I'm am in the same situation of comment by Osama in that post

Dado
  • 95
  • 1
  • 11
  • try to connect with usb and run `adb kill-server` and then `adb tcpip 4455` – Gabriel Mar 21 '20 at 17:48
  • changing the port does not change the result, I see the tcp port open, I disconnect the cable, port closed – Dado Mar 21 '20 at 18:34

5 Answers5

1

Firstly connect your device and check if it's connected or not RUN

adb devices

then RUN

adb tcpip 5555

now disconnect your device usb cable and go to the settings and find out the IP Address of your phone and RUNn
adb connect your_phone_ip_address

eg. adb connect 192.168.1.102

replace with your own ip and check it with adb devices if it's connected or not if it's not working then the problem must be something else

Harvinder Singh
  • 1,919
  • 21
  • 15
  • thanks, as I wrote in my first [update], when I run "adb tcpip 5555" if I scan the smartphone tcp ports I found port 5555 opened, but as soon as I disconnect the cable the port results closed. So whatever attempt to connect to it will always fail. – Dado Mar 21 '20 at 19:02
1

I'm also testing on a Honor phone. I found a solution to solve this problem. You can try to turn on Allow ADB debugging in charge only mode and turn off Always prompt when connecting to USB. It should fix the problem.

Here is the reference for the solution.

Elletlar
  • 3,136
  • 7
  • 32
  • 38
Darren Wu
  • 11
  • 2
1

Bellow commands allows you always get 5555 as default port number, try this out

Make sure you have wifi configured as "auto connect", also set always allow the adb from net work under developers manul

adb root
adb remount
adb shell setprop persist.service.adb.enable 1
adb shell setprop persist.adb.tcp.port 5555


adb reboot
yunfei
  • 526
  • 2
  • 6
  • 20
1

Hello I can solve problem

First of all connect your device with cable (usb debbuging) click on allow on phone if it asks about debugging

Now open cmd

type cd 'Location of scrcpy'

than type the following

adb tcpip 5555

If it asks you again to do adb tcpip 5555 do it again

adb connect <'device-ip-adress'>

Disconnect the device by removing the cable

scrcpy -s <'device-ip-adress'>

Done! Problem Solved

0

You probably don't have The ADB Server running.

With the USB cable connected,
do:
adb kill-server && adb start-server && adb tcpip 5555 && adb connect 192.168.1.110

Once Successfully Connected, You can then Disconnect the Cable.

NOTE: on running adb devices, the device name is now of the format IP:PORT as opposed to the initial Alphanumeric string.

ByronTaaka
  • 36
  • 5
  • unfortunately that is not the case, I don't have multiple adb, I'm using just platform-tools on a machine where nothing else is installed and I already tried your suggestion, but it does not connect if I remove the cable before the "adb connect" command and it connects if I leave the cable inserted... but as soon as I disconnect the cable I loose the tcp/ip connection – Dado Mar 21 '20 at 18:17
  • I have tried it out and got the same behavior as You. However, I found a way to fix it. Updating my answer to reflect how I have solved it. – ByronTaaka Mar 21 '20 at 18:55
  • I updated my question too , because it was a little bit confused, now you can see the steps I'm following, and they works, so my problem is not adb server not running, the problem is when I disconnect the cable, it seems the adb daemon (the one on the smartphone, not the server on the PC) is killed or the port 5555 closed – Dado Mar 21 '20 at 19:13
  • Please copy-paste my updated solution. It Works. Tried and Tested. – ByronTaaka Mar 21 '20 at 19:16
  • Taaka, I believe in you, also here it works, if I run it with my asus tablet, but it does not work with my honor smartphone and you cannot test the same because you don't have the same device – Dado Mar 21 '20 at 19:24
  • Run the same command twice. I may not have the same model, but I'm able to replicate the problem You are facing and on running the same command for the second time(before unpluging), things word. The TRICK is to ensure that the Device name is of the format IP:PORT when `adb devices` is executed. Before that format is achieve, the device will just disconnect. – ByronTaaka Mar 21 '20 at 19:40
  • Taaka, thanks for the time you dedicated to this, unfortunately here your trick doesn't work, no matter how many time I run the command, and the format is correct, 192.168.1.110:5555, the problem is that everything is working fine, but, when I disconnect the cable it get disconnected ALSO from tcp, no matter what I do. It seems to me that there is something on the smartphone that kills the adb daemon and the solution (if any) is probably to change something on the phone itself – Dado Mar 26 '20 at 13:35
  • I have the same problem with honor smartphone, I guess that it is a bug in this model. – Amiad Oct 21 '20 at 15:24