Unable to connect Android ADB over TCP/IP - android

I'm trying to get the Android Debug Bridge working over wifi from my 64-bit Windows 7 desktop computer to my Nexus10. I connect the device over USB, and then I followed "How can I connect to Android with ADB over TCP?, but I end up with an error message that it can't connect:
C:\adt-bundle\sdk\platform-tools>adb usb
restarting in USB mode
C:\adt-bundle\sdk\platform-tools>adb devices -l
List of devices attached
R32D300NXJV device product:mantaray model:Nexus_10 device:manta
C:\adt-bundle\sdk\platform-tools>adb tcpip 5555
restarting in TCP mode port: 5555
C:\adt-bundle\sdk\platform-tools>adb connect 192.168.231.2
unable to connect to 192.168.231.2:5555
To start debugging this, I tried pinging the Nexus10 from my desktop computer. Both devices are connected to the same router, by a cable in the case of the desktop computer, and wirelessly for the Nexus10. However, I got
C:\adt-bundle\sdk\platform-tools>ping 192.168.231.2
Pinging 192.168.231.2 with 32 bytes of data:
Reply from 192.168.231.61: Destination host unreachable.
Reply from 192.168.231.61: Destination host unreachable.
Reply from 192.168.231.61: Destination host unreachable.
Reply from 192.168.231.61: Destination host unreachable.
Ping statistics for 192.168.231.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
The IP address 192.168.231.61 which returns "Destination host unreachable" is the IP address of my desktop computer. Although the ping doesn't work, I don't know whether the fact that I can't ping is the source of my ADB problem or whether it's unconnected to the issue.
I'm running Android Debug Bridge version 1.0.31. Can anyone help?

This must have been a networking problem, because when I connected via a wireless network on a different subnet, then (1) I was able to ping the nexus10 from my desktop, and (2) ADB connected over TCPIP OK. So my conclusion is that my desktop/router/nexus10 had some bizarre routing incompatibility when on the same subnet, when disappeared when they were on different subnets.
Thanks anyway.

I have problems both with my nexus 4 and my nexus 10 on the same wifi as my laptop. The nexus 4 I have had more time to experiment with, and what helps is either rebooting the phone, or using "DNS Hostname Changer" to restart networking and then I can connect again.
The Nexus 10 seems to be a bit worse than Nexus 4 though....

Related

Can't connect through ADB to device's port

I'm trying to connect to a TV set-top box. After issuing "adb connect my_IP_address" I get this error "No connection could be made because the target machine actively refused it. (10061)". I've tried many basic solutions like the ones from this SO thread but they either don't work or I can't attempt them since they require a USB cable connection and my device dosen't respond to that for some reason.
USB debugging is enabled and I'm sure the device is connected to the same network since I successfully pinged it. Surprisingly I discovered that the 5555 port which is usually used for connecting isn't even open. I got that from using Nmap to check for a particular port. Then I used Nmap to see which ports are open and only got 3:
PORT STATE SERVICE
8008/tcp open http
8009/tcp open ajp13
9000/tcp open cslistener
None of those is suitable for a connection and it looks like there is no available port? What can I do from here?
First, you need to open the 5555 port for communication
Step to open the port
plug your device to the pc
issue command to open the port adb start-server 5555
adb connect my_IP_address:5555

No Consistent Way to Connect ADB over TCP

I am debugging an Android app that usually crashes when I plug into an Arduino it is supposed to be communicating with. Consequently, I need to get a wireless connection to the device's logcat, which is what brought me to ADB over TPC as seen on the Android developers webpage.
The recommended process is:
C:\Users\User> cd AppData\Local\Android\sdk\platform-tools
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb kill-server
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb tcpip 5555
restarting in TCP mode port: 5555
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb connect 10.20.5.160:5555
However, the typical response is:
unable to connect to 10.20.5.160:5555: cannot connect to 10.20.5.160:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
I could not consistently get a connection between a PC and mobile device. Over the course of three weeks using several networks and devices, I could only connect two times out of an agonizing many attempts.
I have dug deep into the posted questions on stackoverflow and tried literally every recommended alteration to getting an adb connection, from using an Android Studio plugin to forwarding ports to trying several other ports to toggling my device's internet. I still could not get a connection more than a fraction of a percent of the time.
When I look at the network state of my device after adb tpip <port>, I find no evidence of the device trying to look for a connection:
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb shell
j3ltevzw:/ $ netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 ::ffff:10.20.5.160:4214 ::ffff:173.194.196.188: ESTABLISHED
udp 4288 0 adb shell ip -f inet addr show wlan0:68 10.20.5.1:67 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
... ... ... ... ... ...
... ... ... ... ... ...
Also, when I try to ping my device, I usually get:
C:\Users\Benjamin\AppData\Local\Android\sdk\platform-tools> ping 10.20.5.160
Pinging 10.20.5.160 with 32 bytes of data:
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.
Ping statistics for 10.20.5.160:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)
What I am looking for is a process or file that can be run and consistently open a tcp adb connection, or at least explain what about my setup is invalid. Ideas?
Update 1:
I have started a bounty on this question. I feel like the problem with the ADB software used to make connection for debugging is two fold:
adb tcpip <port> does not always invoke the mobile device to listen on the specified port
adb connect <ip>:<port>, I am assuming, is not given permission by the network to connect; I am not a networking expert, but the fact that pinging a device returns "destination host unreachable" seems a little off
I will award the first person to find a successful solution. Seeing that having an ADB USB connection gives a user access to both the mobile device's and host's terminal, there really is no excuse for a connection not to be able to be made between the two.
Update 2:
I have recently had more success in connecting to the ADB as well as receiving successful pings at my school network. Note at this network connects are insecure and the host and mobile devices where on separate subnetworks. Any idea why these conditions would work over my secure network at home that uses only one subnet?
Try starting from scratch and setup ADB-over-tcp following steps below:
Turn off USB debugging on your device and turn it on again (just to reset).
Kill the ADB server on your PC using adb kill-server
Connect your device to the PC using the USB cable and type adb devices. This will automatically restart the ABD server again.
Enter adb tcpip 5555 on your PC terminal. This will switch the adbd daemon on your device to tcp-ip mode.
Disconnect your device from USB. Now connect your device to the same wireless network as your PC, either the same wi-fi or use your phone as a hotspot.
Determine your phone's ip. You can do this in the wi-fi settings on your phone. If you are using your phone as hotspot, then generally your ip should be 192.168.43.1 (not required but most of the time it's the same).
Connect to ADB via tcp using adb connect <IP>
This should hopefully connect your device to your pc via tcp-ip.
I found a solution that works for me, but I feel it shouldn't necessary and it may not applicable for everybody else with these issues, so its still not quite what I was aiming for.
Anyways, after seeing riyaz-ali suggest what an IP address I should be for using a mobile hotstop through a phone, I realized any network complications would be solved if I was the network, so I connected my mobile device to the mobile hotspot on my laptop.
Instant ping responses and immediate ADB connection with the popularly suggested commands.
Just found myself in the same situation. Had no problem yesterday but today couldn't connect.
Solution was simple, I realized that today I'm connected to VPN which obviously makes me belonging to a different network.
So, disconnecting and connection to the same Wi-Fi solved the trouble.

Android adb wireless/WIFI debug Operation timed out

I followed steps in this post and tried to connect to my Motorola X Gen 2 for Wifi debugging, on OS X El Cap.
I connected my phone to the laptop with usb cable,
I killed and started server, the server was started successfully, and then in:
./adb devices
I got
List of devices attached
TA44909GA0 device
Then I did
./adb tcpip 5555
And I tried
./adb connect <IP addr of my phone>:5555
both with usb cable connected and disconnected, none of them worked. Both returned error message saying:
unable to connect to ***.***.***.***:5555: Operation timed out
I cannot figure out what is happening here, I tried the Android Studio plugin ADB WIFI, which returned the same message, operation timed out. I restarted everything, tried connecting with a different cable and all, nothing worked.
Does anyone know what's happening here?
Make sure your computer and the android device are using the same wifi network. I had the same issue and fixed it after changing to the same wifi.
So after a huge number of trials, I think the problem is somehow wifi related, I think this feature does not work well with WPA2 (or any kind of?) Enterprise encryption, because I was using my school Wifi, and it turned out to be okay, up and running, for the hotspot I set up with another laptop.
What solved this for me:
disconnect the phone from USB cable
restart the phone
reconnect the phone by USB cable
(meanwhile):
adb kill-server
adb start-server
Then follow the "standard" procedure.
If you are connected on same network and still can't connect then check your IP twice . Sometimes it get changed.
check your IP = phone settings -> About phone -> Status -> IP address
Try increasing the timeout in Android Device Monitor.
From Android Studio: Tools->Android->Android Device Monitor
In Android Device Monitor:
Window->Preferences, Android->DDMS.
In the DDMS window, increase the "ADB Connection Timeout (ms)". It defaults to 5000ms. If your app is particularly large/takes a long time to load, it may go longer than this timeout, so increasing may fix it.
If you are using Mac OS.
Check by clicking on the wifi icon in the toolbar. If there is any warning.
In my case there was a warning saying the wifi is using WPA protocol and its not secure.
I went to my router settings and changes the protocol to WPA2/WPA3 auto.
After that the warning went away and the wireless debugging started working.

How to use adb using bluetooth?

I am currently using an API 18 (Jelly Bean) device, and it does not support ADB over Bluetooth by default (No option available in developers option for wireless debugging) I have to connect my device with my Laptop using Bluetooth Personal Area Network which is Bluetooth tethering of my phone. Can anyone help me with starting a TCP open port my phone so that I can connect ADB using the adb tcpip "open_port_no" and adb connect <phone_ip_address>:open_port_no commands?
I have already tried some apps from playstore to do so but they all failed.
You need to enable the TCP port first by connecting a USB cable to your phone and setting it from the console on your PC/Mac:
adb tcpip 4455
Now turn on the Bluetooth on your phone and enable tethering.
You need to use the IP address of your phone. It will most likely be 192.168.44.1 since this is the default. If not:
You can get this using a few methods depending on your computer type:
ifconfig
ipconfig /all
route | grep default
Then connect to your phone from your computer using:
adb connect 192.168.44.1:4455
You should get a response:
connected to 192.168.44.1:5555
This works perfectly for me. Sorry for the late response :) I was just looking for the same thing and happened upon the solution. Sharing is caring.

Android adb forward and own bridge to reach remote server

i have a question about the adb forwarder stuff
My situation:
Ressources: 1 Windows PC where i write my code, 1 Android device (Android 2.2) connected via USB to the Windows PC, 1 Linux Server running inside a virtual Machine (VMWare) on the Windows PC
Task: the android device has to connect the virtual Machine via TCP (Port 65001)
restrictions: I am not allowed to use wlan for that (because of some issues that i can't influence). I am not able to do usb (reverse) tethering because my devices does not have the usb tethering option in the android menu (disabled by the manufacturer).
I am able to telnet the port to the virtual machine (telnet 192.168.1.2 65001) and get my data. So there are no network problems between local and virtual machine. The local ip address is 192.168.1.1.
Now i need a bridge from the incoming port 65000 to the listening Port on the virtual machine (65001). I have used the following command adb forward tcp:65000 tcp:65000 to get a tcp connection over usb from my android device to my localhost (and vice versa). As I know you can't forward with adb to a remote machine.
Now the problem is that i can't bridge from 127.0.0.1:65000 to any other port to get the full communication path. If I try to create a listening connection on 127.0.0.1:6500 i get an error with the message that the port is already bind (because of adb forward tcp:65000 tcp:65000). If the forward blocks all other connection on this port, how can i get the incoming data from the android device?
I've tried to tunnel via putty (localhost:65000 (win) -> server:65001) and I've written a little program that creates a listening server (socket) on 127.0.0.1:65000 and sends the information to 192.168.1.2:65001 via 192.168.1.1:65001.
Has anybody an idea how to solve my situation? If so please explain. Maybe this helps others too to handle the adb forwarding function.
hint: The Ports and addresses are only examples. The only fix port number is the listening port on the virtual machine

Categories

Resources