TCP connection from phone to debugging host - android

I'm developing client/server software for Android.
While connected to the phone via USB debugging, I'd like to access the webserver I'm running on my developement PC - using the USB connection.
Is that possible and if so, how ?

I stumbled upon the answer after a night sleep.
Enabling USB tethering on my phone (N1, 2.2.1) gives it and the host computer an IP address. The phone can communicate with my web server running on my developement machine!
(Chris, the rumors are right)
Just make sure your web server is listening on that IP address. For apache, use the line
Listen 80
or
Listen x.x.x.x:80
(x.x.x.x being address of your android tunnel)

The easiest way to do it is via wireless. If you don't have wireless, I'd say bite the bullet and get it, it's going to be a necessity for testing anyway :)

Typically the USB only supports connections from the development machine to the phone (via adb port forwards) and not the other way around. Of course once a connection is created data can move bidirectionally. One could use this to build a tunneling proxy web proxy (one connection in from the development machine to a daemon running on the phone, outbound connections from the phone then tunnel through this)
I have heard rumors though that what you want to do - often called reverse tethering - may be supported in some more recent devices.
Kevin's wifi suggestion may be the simplest with a real device.
On the other hand, unlike typical phones, the android emulator can directly access the development machine's loopback interface at an alias address given in the documentation.

Related

How do I capture Android http traffic using charles or wireshark (which is on PC) under VPN connection?

I have googled a lot about setting up fiddlers for capturing android traffic. I have tried each of the suggested options. None of them work when there is an active VPN connection.
Setup: Charles or Wireshark is available on PC. Both PC and android device are on same network and on seperate VPN connections.
Tried approaches:
Configuring Wireshark/Charles – Created a new adhoc wireless network and making the android use the same. Another way was making the laptop as a virtual router or hotspot. None of these methods work when it comes to VPN.
Using TCP/IP monitor available in eclipse – This is a great tool built in eclipse, but needs hostname and port. For the internal website I do not know the port. Since it is standard http setup, I am assuming it should be either 80 or 8080.
Using different fiddlers available on Play store – All good fiddlers like tcpdump need the phone to be rooted and that’s not an option for me.
Tethering of PC network onto mobile - This again fails when it comes to VPN (damn you, VPN)
Anyone with any insight, most welcome !
Thanks!
Have you seen this approach? Have you configured proxy on you device connection?

Osc communication between laptop and tablet in same WiFi network

I want to let my laptop and tablet communicate via OSC using OscP5 java library.
Tablet is android device and application is made on android studio.
Laptop is Windows 8.0 and application is running on Processing 2.2.1. Both uses same library OscP5.
WiFi network is very huge and strong in public government office. Both devices are obviously in same WiFi network named - Public WiFi Free. Both devices are using wireless(WiFi)
What I'm doing is very simple.
Send some integer from tablet to laptop through UDP unicast.
When I confirm IP address,
Laptop : 192.168.25.219
Tablet : 192.168.26.83
It's strange that they have different address which are 25 and 26.
I tried to reconnect on both device many times, but they always get same IP.
Problem is not port. I certainly confirmed that port is same(13000).
and laptop is just listening 13000 port and not sending anything.
Tablet is just sending to laptop IP on 13000 port.
I searched a bit and people are saying that if 1st, 2nd,and 3rd part of IP address is not same, OSC doesn't work. Is this the problem? and if so, Why? I'm kind of noob about network so please explain easily..
Problem was firewall...
Anyone who came to this post must confirm whether firewall is blocking your port or not. There are 2 possibility that firewall is blocking your port on router level or your OS level.
The first case, you have to access administrator setting page of your router and enable VPN(Virtual Private Network) pass-through or open port.
The last case(mostly in Windows because firewall is option in OS X), you simply go to settings and disable Home network level firewall, or you can add exception for you port.
I hope someone will not have hard time like me because of firewall.

Accessibility of XAMPP either with usb plugged into the pc and use pc's internet connection or vice versa

I have no networking background. I would like to apologize if the terms that I used in my question below are incorrect. Your help is appreciated.
1) Recently, I am developing an android app which involves google map api and xampp. I can access database on the phone browser(192.168.x.x:8080/folder/getdetail.php) when my android phone (4.1.2) is connected to my pc and used my pc's internet connection. But after I unplugged the usb from my pc and used wifi, I no longer can access the same link as mentioned above on my phone. May I know what is the problem and what tools or skills that I need to look for?
(2) If the above mentioned problem is solved, I am also looking forward on the way to make xampp to be accessible over the internet. For instance, my pc serves as a server at home and I can connect to the server and retrieve some data from the db when i am elsewhere.
P/S: My pc is using wireless internet connection.
Unfortunately there's too few information on your network and your pc. Let's assume you're using your Windows-PC and Phone on the same Network and you didn't change any web server settings and didn't move the XAMPP folder.
XAMPP is running an apache Server which is listening on TCP Port 80.
First you should check your firewall. Windows is using 3 different Profiles.
if you connect your phone and an additional network is set up with a different profile this could be the reason.
http://www.windows7library.com/blog/wp-content/uploads/2011/06/Network-and-Sharing-Center.jpg
If you want to access your XAMMP from the internet you should forward a TCP port to port 80 on your PCs LAN IP-Address.
http://en.kioskea.net/contents/280-nat-network-address-translation-port-forwarding-and-port-trigg
http: //en.wikipedia.org/wiki/Port_forwarding
But please only do that for testing purpose since outdated webservers/modules/scripts can actually harm your system. Use XAMPP only for development and testing.
My advice if you still want to do it forward some other port >10000 to your local port 80.
To access it you have to add the port to your url like this http: //127.0.0.1:8080/

WiFi-Direct communication between Mac/Windows and Android

Is it possible to let an Android (>4.0) device establish a WiFi-Direct connection with a Mac OS or Windows device?
According to the Wifi-Direct Docs the protocol allows:
Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi
It doesn't look like Google provides this functionality via the API. Although WiFi-Direct isn't a proprietary protocol and could be implemented for any platform. There are a few posts around the web of people trying to get Wifi-Direct to work under windows:
Broadcast message from Desktop PC to Android Device using WIFI connectivity
https://superuser.com/questions/417888/how-do-i-connect-a-laptop-running-windows-7-to-an-android-phone-using-wifi-direct
http://www.intel.com/content/www/us/en/wireless-products/my-wifi-technology.html
http://androidforums.com/android-lounge/552970-howto-wifi-direct-use-your-laptop-desktop-softap-android-reverse-tethering.html
All you need is to use java.net.Socket. Depends on what do you mean by establish direct connection. TCP connection is established when on destination device (windows or mac) you open listening socket by ServerSocket. On other device you can use Socket with destination address. Of course, windows or mac box will propably have to open that port in firewall.
I guess what you actually need to know is how to get name of target computer or how to discover computers on local network. Unfortunately, it does not depend on android version I think. You should check http://en.wikipedia.org/wiki/Zero_configuration_networking about some hints. I fear there might be problem in need to open privileged port on android, as normally you have to be root for that. And that would require rooted android.
Of course you should specify what do you intend with that direct connection and what software do you need. If both ends have your application, you can just open any not allocated and unpriviledged port on android. Use UDP to broadcast periodically name of android device (propably ask user to enter name of his device). Use multicast to send requests, and receive replies the same way. Multicast sending and receiving would require your application on android and on windows and on mac also. Now you can read from multicast application what type of machine it is, and what local port it left open for your direct connection. From source of udp message you know where to connect.
You may use some framework to speed things up. All this require some knowledge about networking, but I don't know simpler and well working solution. Unless you provide details about what is your direct connection to do.

Connecting to an Android emulator on another machine

I need to test my android app 24h a day and I have 3 ubuntu boxes to do it.
I would like to connect my development system (MOTODEV Studio 1.3) to a Remote Device.
The interface asks me for an IP address and port for the machine to connect to.
But it doesn't connect. I found that the adb sever on the remote machine doesn't seem to listen to external ports, only internal loopback, making machine-to-machine connections impossible.
Is this true? If so, why there is a section on Device to connect to Android Remote Device on MOTODEV Studio?
I've found an explanation and a workaround in this post (http://rxwen.blogspot.com/2009/11/adb-for-remote-connections.html) but it seems complicated and the post's links don't work, so I'm confused whether there is a solution to do that.
It seems so simple..... I can't believe there is not a way.
The Remote device feature of MOTODEV Studio is intended for TCP/IP connections to a remote phone. It requires a lot of manual intervention at this point to get things working and it's an area where we're definitely in need of better documentation.
I don't have the full workflow in front of me, but the steps you need go like this...
Connect phone to remote host.
Using adb shell on remote host, set the phone to connect over TCP/IP rather than USB. You'll need to find the IP address of the phone manually. If you're using a Motorola phone and the Motorola drivers, it's probably 192.168.16.x
Set up port forwarding from the remote host to the phone for the debug ports (probably 5554 or 5555).
From the local host, set up the address of the remote host in the IP field.
When choosing "Run as" or "Debug As" from the local host, you need to choose the remote device as your target.
We intend to make this workflow more automated in the future, but for now you have to do this manually. It's my observation that remote debugging of embedded systems is still slow and prone to problems with latency and line quality, regardless of whether we're talking about phones or reference boards.
Good luck.

Categories

Resources