adb wifi often go offline, how to keep adb online?
Asked Answered
S

7

10

I'm using Android tablet communicating with a USB device through USB port, the tablet only has one usb port, so I use adb wifi as my debug tool. However, when I connect adb through WIFI, the connection won't keep long(only a few minutes us usually), how to keep the adb wifi connection online all the time? Another question, is it possible to use USB HUB to connect the tablet with both USB flash-drive and my computer, and keep adb running? Many thanks!!!

Sessions answered 29/7, 2016 at 6:25 Comment(1)
you can check the file at gist.github.com/kamleshkarwande/…Eventual
L
9

After lots of unsuccessful attempts,I have noticed that turning Allow ADB debugging in charge only mode specification on , solved the problem . It makes the device online and accessable over wifi to ADB. You can find it under Developer options section.

Lucid answered 6/8, 2020 at 5:47 Comment(0)
K
5

Here is what I found out from researching everywhere and developing on my own for more than a week.

Q1. adb service often crashes if it is not doing any executions for a long long time.

A1. calling adb commands time to time keeps adb server online.

Q2. wifi connected device sometimes disconnect.

A2. Before you check your wifi on the connected device, check the wifi that your ADB server is running on. Ping to google and if it is well connected, ping to the device.
Wireless can disconnect on its own and even wired connection is sometimes disconnected. so calling "adb connect ..." when the device is not already connected is necessary. You could do this easily by saving "adb devices > device.txt" and query out whether your expected wifi is on the list. If not, connect again..(do this in another thread).

Q3. wifi connected device is sometimes offline.

A3. This is because by TCP/IP connection your ADB server is now on Time_Wait stance. The last connection was interrupted that the next connection is now offline because the last connection is not completely shut down. You can either manually disconnect/connect your device's wifi or restart TCPIP connection by ex) "adb tcpip 5555" If you want to do this automatically, you are going to have to disconnect/connect your device's wifi programmatically.

Leave any other questions and I can answer on the comments.

Krieg answered 19/6, 2017 at 2:49 Comment(1)
hey,... is it working if we disconnected and connect it back in a loop with a delay?Khufu
D
3

When connection is lost and adb devices shows device is offline, like this:

prompt> adb devices
List of devices attached
192.168.1.1:5555     offline

then adb disconnect IP followed by adb connect IP will often work:

prompt> adb disconnect 192.168.1.1
disconnected 192.168.1.1
prompt> adb devices
List of devices attached
prompt> adb connect 192.168.1.1
connected to 192.168.1.1
prompt> adb devices
List of devices attached
192.168.1.1:5555     device
Diphyllous answered 20/9, 2017 at 0:1 Comment(0)
P
2

Use adb over wi-fi without any third-party apps. Follow the steps.

  1. Connect device via USB

  2. Open your terminal and check your device is listed with adb devices command

  3. Type adb tcpip 5555 and enter (or use another port instead of 5555)

  4. Plug out your USB cable. You don't need it anymore.

  5. Take your Android phone and go Settings/About/Status

  6. Check the IP address part. Let's say your IP address is 192.168.x.y

  7. In your terminal, write the command adb connect 192.168.x.y

  8. Now, you have connected your device via wi-fi.

  9. You can see your device in adb devices

  10. Enjoy it! :)

Poche answered 29/7, 2016 at 7:17 Comment(7)
Thank you for your answer! This is what I used to do. However, I want get rid of the USB cable completely, I installed WiFiAdb on my tablet, whose connection is often lost. Do you konw the reason?Sessions
What do you mean by saying "get rid of the USB cable completely"? After these steps, when you will use your cable?Poche
What mean is I don't go through step1, using Android WifiAdb.apk instead.Sessions
I have had an issue with this method where after some period of time passes, I am no longer able to connect. (I am using a Play Store app that connects to port 5555 directly on the phone). When this happens I am out in the field away from any device that can connect and re-run adb tcpip 5555 and so I am unable to catch logcat to debug whatever issue happened when I am back at my desk. How do I prevent this from happening?Decanter
Try adb kill-server and then adb start-server. Then apply these steps again.Poche
Great! Thanks !Scandalize
Won't work for long. As soon as you reboot, it will forget these settings and you will need to do it all over again.Senter
F
0

This seems like an issue with your wifi. As a precaution, just keep the terminal open and whenever you need to test just press the 'UP arrow' key to get to previously ran adb connect "<ip>" command.

Fahey answered 29/7, 2016 at 6:30 Comment(2)
my wifi transmitter is very close to my tablet, the signal level is very high, however, it seems that has nothing to do with the problem, I have to use "up" very frequently, but this is very awkward.Sessions
Hmm..I still believe thats a problem with your router. Is it being shared by a lot a devices? If yes, then the router may decide to randomly drop devices temporarily and in adb's case that means total disconnection. You can build a small test app to check how many times connection drop occurs to be certain.Fahey
A
0

I tried many ways but this one worked out for me: force the display on and of in a loop would keep the device online

adb shell input keyevent 224
timeout 2
adb shell input keyevent 26
timeout 58

this turns the display on every minute for 2 seconds

Agram answered 12/9, 2020 at 14:53 Comment(2)
How can this be done in a loop?Teratism
on a mac I tried it with while :; do clear; adb shell input keyevent 224; sleep 2; done. The connection remains stable for a longer time, but after a while it breaks again :o/Outcry
K
0

So, I'm using Scrcpy and Adb to wirelessly connect to my Phone(for developing Flutter Apps) and since the screen wasn't staying awake even by Scrcpy --stay-awake command.

I had to change Lock Settings=>Lock Screen => Sleep, and settings to Never Sleep.

Kure answered 11/8, 2021 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.