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.
Related
I want to create a mobile browser app.
I am using ionic within wsl within windows 11.
Now when I do ionic serve --external I want to access the web app from my phone browser.
I am on a public train wifi, so maybe that's why I can't connect?
This is the output from ionic (extract):
[INFO] Development server running!
Local: http://localhost:8100
External: http://172.21.17.144:8100
My phone is on the train network as well. I can access the external ip from my laptop (host), but not from the phone. The phone browser gives timeout message, when I try to connect to the external ip.
I also tried to connect via hotspot. I created a hotspot in windows 11. Connected to it from the android phone. Unfortunately I couldn't connect to my laptop via the hotspot network either (ip: 192.168.37.1). Also I didn't see network adapter that was hosting the hotspot in wsl via ip a.
Please, how would you connect to your dev server, that is running on your laptop, from your phone, without too much headache?
Please, how would you connect to your dev server, that is running on your laptop, from your phone, without too much headache?
There are several options. The first is definitely the easiest, if it works for you.
WSL1
In general, networking is "easier" on WSL1, so if the tools you are using work there, it's okay to keep using a WSL1 instance for them. You can have a separate WSL2 instance if you'd like for tools that work better there.
WSL1 runs as a syscall translation layer in Windows, and as such it shares the same network interface as Windows.
WSL2, on the other hand, is a virtualized environment, using a virtual NIC behind a virtual Hyper-V switch. The WSL2 network is NAT'd behind/inside the Windows network, which is why you can't see it from other devices on the network.
WSL2 does provide a feature known as "local forwarding" that allows the Windows host itself to access WSL2 through the localhost address. However, that doesn't extend to other devices on the network.
So if you do need to use WSL2, there are other solutions:
SSH Reverse Tunnel
My personal preference at the moment, since it simplifies forwarding and firewall rules. See my "Option 2" in this Ask Ubuntu answer for instructions.
There's some one-time setup that might take 10-15 minutes, but after that it's a one-liner to connect the ports before you run start the server.
Bridged network interface
You mention that you are on Windows 11. As long as this is a Pro version or higher (not Home), you could use a new feature in the WSL Preview release to create a bridged Hyper-V switch. I have not tested it myself, but you can find details in this blog post.
Traditional port-forwarding method
The method recommended in the Microsoft Docs is currently to use Windows port forwarding through the netsh interface portproxy command to route the traffic to WSL2. The problem is that the WSL2 address is dynamically assigned each time it restarts), so you have to determine or parse the correct address after each reboot.
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?
I am trying to debug my visual studio 2012 asp.net project from my phone and have followed all steps here and here.
However none of them work, can't even connect from my other laptop. When I add my public IP or use * IISExpress doesnt even seem to pick up on it (Can't find it in IISExpress->show all applications). But When I used my local IP at least it showed up there and I could connect to it from my own computer, but no other computer/phone.
The cmd commands are successful, I add the extra binding, I open the firewall. Dont know what is wrong.
Which IP (local/public) should I use? what should I type in as URL when I want to test it? I am trying http://IP:port and http://IP:port/Default.aspx.
EDIT: Using this solution I got it to work on my laptop, however I still can not get it to work on my phone.
Basically, the points mentioned in the links you have cited are enough for enabling communication with the phone. But here is one point to make sure (since you have not mentioned it): You have to make sure that both the server and the clients (in your case, the machine that runs the visual studio and your phone and the other laptop) are on the same wireless network. To find out the IP that your server/development machine is currently using, you can issue ipconfig command in cmd and look at the Wireless Network Adapter IPV4 address. For example, if your laptop IP address is 192.168.1.2, you should use http://192.168.1.2:8080/Default.aspx (assuming that your site runs on the port 8080).
You use the local IP if you're on the same network as your server (for example, use WiFi on your phone and join the same network that your server is on).
You use the public IP if the device is outside your network, and you have to configure the firewall to forward the correct ports to the local IP. That's NAT traversal. This would be if you're using the phone's cellular data connection, or you're using a WiFi or wired network that's different from the one your server is on.
Your URL should always be of the format <protocol>://<IP or DNS name>:<port>/<path>. However, you can omit the IP (and the colon) if you're using HTTP on port 80, or HTTPS on port 443. And you can omit the path if you're accessing the root of the site, and your site has a page correctly configured for the root (either via default document in IIS, or route defaults if you're using routing features).
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.
I wanted to know if it is possible the comunication between two Android Emulators started on two different machines networked.
For example
- Emulator A run on machine M1
- Emulator B run on machine M2
Can A and B exchange messages?
If yes, what ip address do I use?
Thank you very much
Deborah
You might know this already. As of android-sdk-tools_r7 it should at least be possible to connect two emulators to each other. Whether is works between physical machines is not something I know. It might be possible to set up masquerading between the two hosts for this specific broadcast.
From the android commit
Enable interconnection of emulators
This patch adds a -shared-net-id option to the emulator which
joins the emulator in a shared network.
If the option is given the emulator is started with an additional
network interface bound to a multicast socket. This multicast socket
emulates a network hub, interconnecting emulators.
If the -shared-net-id option is not given, nothing changes.
To connect two emulators, use the -shared-net-id <number> command line option when starting the emulator. They will then directly share everything sent to or read from ip 10.1.2.<number> on the emulator.
Another approach would be to enable port forwarding between the emulators using adb, and then set up masquerading for those ports on the networked machines.
I'm not really sure that either of these solutions match the use case that you're asking after. If not, adding more details to the original question might help. :)
Disclaimer: I have not tried the first approach, and the second I've only used to make sure that an emulator could bypass a nasty corporate firewall and HTTP proxy so that we could test the android browser. The principle should be sound though.
Update:
Nope, I played around with it a whole lot and found no nice solutions. I am not good enough at iptables to set up a valid tunnel that way that works for the server end.
Regards,
Mikael
An emulator normally has outbound access to the development machine's LAN or internet connection, so the problem is on the inbound side.
You can use an emulator or ADB port forward to send traffic into the emulator, but possibly only locally originating traffic on the development machine's loopback interface, and not external traffic. If that is indeed the case, the simplest thing would probably be to write or configure a port forwarder that listens on the development machine's external interface and forwards to the port that is forwarded into the emulator.