worklight server root URL fial to connect in android device - android

I try to deploy a worklight application into my android device (HTC Desire), without any hope I get the following error:-
Request timeout for [ANDROID IP :8080/console/apps/services
Default options: on failure timed out for
http://ANDROIDIP:8080/console/apps/services...
Make sure the host address is available to the app (especially relevant for android and iphone apps]
I find my android IP address via whatip.com and I configure my application descriptor xml file with it.
it works with android emulator when I use the following
<worklightServerRootURL>http://10.0.2.2:8080</worklightServerRootURL>
but not with the mobile device
any advice?

worklightServerRootURL should point to the public IP address of the host machine, not to the device IP.
The device and Worklight Server must be in the same network (public Internet, wifi...).

10.0.2.2 is a special address that only works on the android emulator. On the emulator, it is routed to the host where the emulator is running. On an actual device, this address won't be routed anywhere.
As Idan said, the Worklight server must be reachable from the Android device. This usually means that either the Worklight server has an address that is reachable from the internet, or that the android device has a wifi connection to the LAN where the worklight server is running.
Assuming that you are trying to test using the test server in worklight studio, first determine your computer's IP address. If you are behind a NAT router, whatip.com returns the IP of the router, not of your computer. Use ifconfig (ipconfig on windows) at a command line to determine your computer's IP address. Your computer may have several IP addresses. It is important that you choose the ones that corresponds to the LAN where you will be connecting your Android device. If you are unsure which one this is, you may need to look at your router's configuration. Next, verify that your computer's firewall has port 8080 open. Then connect your android device via wifi to the same LAN as your computer.
To verify that your device can reach the worklight server, try opening the worklight console in the phone's browser. (http://[IP of computer]:8080/console) Once that works, you should be able to use the same IP in the worklightServerRootURL to build the app so that it will work on that device.

Related

Connecting mobile phone to a computer localhost

I'm developing a web application (I'm using MacOs) and I would like to see the screens on my android mobile device. Although both devices connected the same network I couldn't connect computer's IP address and local port on my phone. I'm thinking of this issue is showing up by MacOs. Because when I run same project in to Windows machine I can connect to the IP address with my phone. I've tried a couple of things but I couldn't solve the issue. What should I do be able to connect my phone to the computer's IP address ?
Go check how can you create a server with a "real world" link using ngrok (https://ngrok.com).
I assume Nodejs application only bind to your local (MacOS) and only can access from your laptop. The option is using Nginx or Ngrok to open application to LAN or world.
If you want allow other devices from LAN to connect to your Mac, you can go to System Preferences > Security & Privacy > Firewall then Off.

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

How to connect to a local server from an android emulator?

Started a local server in my computer with IP 127.0.0.1 listening on port 3000.
However, I am unable to access it via my android app when I run the emulator on android studio. I got a timeout error from my app's networking library, so it is not making connection.
Use the IP address 10.0.2.2. You can read more at here.
On each Android emulator Android Studio runs a router for it in order to isolate the emulated device from your development system. Thus in order to access a local server running on your development system (your laptop, desktop, etc) you must use the special IP of 10.0.2.2 and the port the server is listening on. To learn more read this page.

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

android connect to PC's localhost when debugger on mobile device

I want to debug my android application, I connect the android device to my PC using the USB cable. In my application there is a button to connect with localhost, ip for localhost is 10.0.2.2 and the port is 8080, I have read that when debugging on mobile, the ip 10.0.2.2 is the localhost for android device and not for my PC, so what changes should I make to the ip instead of 10.0.2.2? or do I have to make another change?
In this case my android device is sony ericsson xperia arc s.
Google has added support in Chrome 29 and higher to use reverse port forwarding to access a website hosted on your local development machine through the USB cable on Chrome for Android. Setup instructions can be found at the following URL:
Android Remote Debugging - Reverse Port Forwarding
Tools for Web Developers - Access Local Servers
As of desktop Chrome 30 Reverse Port Forwarding is no longer an experimental feature in Chrome. It can be accessed by typing about:inspect in the address bar of your PC, and by clicking the "Enable port forwarding" check box and clicking the "Configure port forwarding" button located to the top right of the window.
Once that is done, connect your mobile device via USB. Open Chrome on your mobile device to localhost:8000 (or whichever port you have configured on your local server).
The Reverse Port Forwarding functionality will make sure that your Android device now sees your PC's localhost.
As 10.0.2.2 is your system (pc)'s local host address (from emulator only). Actually android doesn't recognized localhost in url. so 10.0.2.2 is for that meant. Also for android device loopback address is 127.0.0.1.
Your url with 10.0.2.2 is correct. Also you can use Static IP of your system.
Just check for
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
in your application's manifest file.
EDIT:
Here you are using port 8080 so, try with adb command on your host machine.
adb forward tcp:8080 tcp:8080
Also please elaborate on this line "i want to debugger my application on my mobile".
Note:
If you are going to test on real device use your Network IP of system (PC).
For that you need to make some changes in your xampp server... Assign 1 static IP address to your system and then you need to put your xampp server in online mode. after that you can use that ip address in your android application instead of 10.0.2.2. Works fine for me as i am using my localhost with my android application.
You can share your Mac's Internet connection over Wi-Fi. Then your Android app can connect to a Servlet running on the Mac with HTTP over Wi-Fi. The steps are:
Run System Preference on Mac
Goto "Sharing" tab
Turn on "Internet Sharing"
Select "Ethernet" in the "Share your connection from" combo
Select "Wi-Fi" in the "To Computers Using" list box
Use "Wi-Fi Options..." button to configure Wi-Fi security. Now your Mac is a Wi-Fi server, and it is sharing its Ethernet Internet connection.
Configure your Android device's Wi-Fi to connect to your Mac (in Settings command)
On your Mac, goto the Network tab in System Preferences, and select Wi-Fi in list to find out the IP address of your Mac on the Wi-Fi network (for me it was 169.254.66.223)
In your Android App you can now connect to the Servlet in your Mac with "http://169.254.66.223:8080/YourServer/YourServlet"
I think you have two options
The first one is using 10.0.2.3 when you use your real android device.it works for me.
Your Second opt is creating hotspot from your pc and connect your android device to the hotspot.
Find the ip address using cmd type "ipconfig" replace localhost with the ip address.
Thanks.

Categories

Resources