Debug mobile app from Chrome - localhost not resolved - android

I remember with another phone I was able to debug my local website dev, now there is a problem preventing me to open localhost in my mobile and cannot find how.
Looking at:
Google Chrome for Android Remote Debugging - "localhost:9222" Not Available
my phone is connected, on localhost:9222 I can see a list of tabs.
I can access tabs loading site from remote, but cannot load my localhost.
In one case, error displayed:
408 - Timeout.
On another , simply chrome display site is not reachable.
ERR_NAME_NOT_RESOLVED
I tried both with port-forward enabled as well as not (if enabled, listening to 8081, 8080).
Phone is connected via USB but seems cannot reach my localhost address of the laptop, still on same wifi spot.
EDITED
I remember with another phone I was able to debug my local website
dev, now there is a problem preventing me to open localhost in my
mobile and cannot find how.
I was doing with Bonjour- the "Bonjour host" is the name Mac assign to your user machine user.local. I was able to connect former android host, but now it cannot be solved anymore unless of IP.

The two devices should be on the same network and it won't be localhost in that case, but you have to replace localhost with the IP of the server PC!
So instead of localhost:9222, it would be 192.168.1.10:9222 giving that 192.168.1.10 is your IP address!

Related

How can I connect an android client to my XMPP (ejabberd) server, hosted on my local machine (Windows based OS)?

I want to test my ejabberd (xmpp) server, which I've hosted on my laptop, which is working on windows 10 based OS. I want to connect my android client to this server. So I went on to the internet, and found some solutions. But they seem don't work for me. This is what I've tried:
1.) Create a hotspot on a phone. Don't use data/wifi connection, as server is already on the machine.
2.) Connect the laptop to the hotspot.
3.) On cmd (running as admin), type 'ipconfig', after starting xmpp server (Obviously).
4.) Copy IPv4 address (External IP), and access web panel on the mobile browser through it.
So, I hurried toward my phone, and typed
http://[IPv4 Address]:[port open on the server for incoming connection/5280]/admin
But it(browser) throws 'Can't reach the webpage' error.
When I run
http://localhost:5280/admin
on my laptop, I could easily access my web portal, but It's unreachable on my android phone. What can I do now?
Well I solved this problem by accessing IPv4 of my laptop through my wifi router, and connecting to the port of my server through it. Initially, my browser (both of my laptop and my phone) weren't able to reach the server's port. But I later figured out it was problem in my .yml configuration file. Server wasn't set to listen all the IPv4 calls, instead it was listening to all IPv6. So I changed this, and it then become accessible to all devices on the same wifi. So it was my bad idea to connect it through the hotspot :P

Connecting Localhost with external device for testing

I am developing android app using Google Cloud Messaging. I am using external server xampp and testing it on external mobile(no emulator as it is slow). This is basically chatting app. I am facing problem in getting connection.
I know i need to use http://10.0.2.2:8080 ip for testing if I am using emulator in my client code.
and somehow I need to use router ip http://192.168.x.xx:8080 if I want to test it on external device. I need some guidance as how to configure things to make it possible.
Thanks
Deepak
You can do it with Google Chrome port forwarding as mentioned below
Step 1:
Enter chrome://inspect/#devices as mentioned below in your desktop chrome window
Chrome window will also show the device name, model number, and the ip address.
Chrome Remote Debugging Devices Detection
Step 2:
Add the port in the ports to forward it and to be accessible on the device as shown below.
Click on the button Port Forwarding and check the Discover USB devices.
You will get a small modal as below, where you can enter your localhost address and access it via app on the external devices easily.
Then, after adding the address, check the Enable Port Forwarding.
You are all set done for accessing it on the external device.
Chrome Port Forwarding Settings for Remote Debugging on Android
Chrome on your Android external device also should be open simultaneously to view the output.
Step 3:
Then use the url opened up in the device in the App to directly test on the External Device
Desktop(Development Machine)
Android(External Device)
Note:
1.The device should be connected with a USB cable to the development
computer which has forwarded the port, else the connection is lost.
2.This mode is not available in Incognito Mode in Chrome
If its external but still local (not on the internet), then both have to be on the same network.
make sure you can access the app its self using the ip address.
Try to enter it into your browser, if you can access the app, then proceed to using it as the ip in android.
you can use tools like Connectify(windows), ap-hotspot(linux) to setup a network ip. which your phone can connect to.

How i can connect from localhost to android emulator?

Many people ask about "How get the connect from a emulator to localhost". I am asking about a reverse issue. I created a tiny http server in android app. I know his ip address and want to connect from my chrome browser to the app. If i use my a phone it is no problem, because app use "outer" ip, but in local net wifi. When i use a emulator on a development machine and open in browser ip 10.0.2.15 then can not get access to app in emulator. I tryed any ways - loopback, forward ... all is not working.

Cannot browse site hosted on local machine from a mobile

I generated empty backbone application from backbone-generator on my OS X 10.9.1. Then changed the connect hostname in Gruntfile.js to '0.0.0.0' and start the app.
The issue is that I cannot access the application from Android connected to the same home wifi network. I know that my local machine ip is 192.168.1.101. So, I typed in a mobile browser 192.168.1.101:9000 but nothing is loaded.
I have found several similar questions on SO:
How to browse localhost on android device?
Android cannot access localhost?
But the answers did not help me and I cannot comment on them because of my low reputation.
Could anybody help with this issue and say what I'm missing?
It turned out that the issue reason was in the router wifi settings. The "WDS Settings" was disabled and to let devices communicate over network it should be enabled.
Questions that you reported deal with a local http server running on Android, in your case the application is running on your local machine, so it is necessary that your local machine and Android phone have IP addresses in the same subnet.
If you need to assign an IP_ADDRESS to your local machine (wi-fi interface), you can run in the Terminal
sudo ipconfig set en1 INFORM IP_ADDRESS
it may be useful for development purpose.

Android Simulator how does it connect to local IP addresses?

I am trying to implement an Android application in Windows 7 using Eclipse. I am trying to connect the Android simulator to the local test server in my company, but for some reason, it cannot connect to the test server.
If there is any settings or configurations for this, please let me know.
I have tried to do the same from a MAC machine using iPhone emulator and I am facing the same problem. How would this emulator connect to the local servers in my company as currently it all goes to live servers? What configurations are required to be done on the simulators, and how?
If I try to connect to the test server from normal Windows machine browser, I am able to successfully connect to it through the web browser; but when I try to do the same from the Android emulator browser, it cannot connect to it.
The emulator points to the live network and not the local network in my company. This is strange and I know that I need to do some settings for it, but I am not sure where these settings are done and how.
If accessing local computer:
http://localhost:8080/MyLocalServer.html // URL to use in computer browser
http://10.0.2.2:8080/MyLocalServere.html // URL to use in emulator browser
Also try using a local IP to connect to any local servers. Do not use host names.
Dont:
http://mylocalserver.org/
Do:
http://192.168.1.125:portnumber
You have to set up IP-based hosts instead of name-based.
Emulator its - VM. This use virtual network connection. I think you need before chech this connection (this connection may bee stay as NAT, Breedge, Native IP adress, Proxy).
Since you do not work iPhone emulator, most likely you, IP adress virtual network connectionб which uses Emulator, does not match the address area of the local network, and routing occurs
This may help you...
Taken from the android docs:
If you need to refer to your host computer's localhost, such as when you want the emulator client to contact a server running on the same host, use the alias 10.0.2.2 to refer to the host computer's loopback interface. From the emulator's perspective, localhost (127.0.0.1) refers to its own loopback interface.
http://developer.android.com/guide/faq/commontasks.html#localhostalias

Categories

Resources