IBM Worklight - "The Connection to the server was unsuccessful" - android

When I preview my application in Worklight Console, it successfully connects to the Worklight Server, but if I run the app in the emulator I get this error:
The Connection to the server was unsuccessful.
(file://data/data/com.TestApps/files/www/default/TestApps.html).
I have changed the worklightServerRootURL value, but it is not helping.
<worklightServerRootURL>http:10.0.2.2:8080</worklightServerRootURL>

Is the worklightServerRootURL value in your question the actual value you've placed? You forgot "//"... it should be: http://10.0.2.2:8080.
That said, the IP address seems weird. Make sure that this IP address is the same IP address used for the machine Worklight Server is installed on (the Eclipse with the Worklight Studio plug-in...).
You can do this by opening a CMD window and typing ipconfig. Choose the correct IP address and use it instead of 10.0.0.2.
When previewing using Worklight Console, you're loading the web resources sitting in the server, so there is no problem there (you're connecting to localhost).
When launching the app in a device/emulator, the app tries to connect to the Worklight Server, so you need to make sure to use the external IP address of your server machine. Also make sure that both the server and device/emulator are in the same network.
To make sure the device is in the same network as the server, open the emulator browser app and try to load this URL: http://your-ip-address:8080/console (use the same IP address as in worklightServerRootURL).

Related

How to access url with hostname on laptop from android mobile app

We have mobile apps installed on Android mobiles and ASP.NET Core web API application deployed on IIS server on Windows 10 Laptop / PC.
my Android phones and laptop are connected to the same WiFi network created with Mobile Hotspot on Laptop, we can reach the IP address from mobile and also able to call web api. (Note: we are not using Wifi Routers)
Scenario 1: Working scenario
Web API deployed with default settings and if access with laptop ip address we are able to hit api successfully.
But due to dynamic nature of the ip address on laptop we have to change ip address every time in mobile app. We would like to avoid this situation by using hostname.
Setting static ip address on laptop is also not solution for us. So we have planned following scenario.
Scenario 2: Proposed solution
Web api application deployed on IIS 10 on laptop, with following settings in IIS
Binding Section :
IP Address: All Unassigned
Port : 4041
Host name : xyz.com
Also made the entry in the host file as
127.0.0.1 xyz.com
Now I am able to access the Web-API from laptop browser with the URL: http://xyz:4041/.
When I use the http://xyz:4041/ on mobile browser I am getting error “the site can't be reached” & “refused to connect”
Pls help me to resolve this issue.
There are many reasons for this error, you can try the following methods to fix this issue:
1.Clear cache and cookies and try again
2.Reset Your Chrome Browser Settings
3.Restart the DNS Client
4.Change the DNS Servers
5.Flush the DNS Cache
6.Reset the TCP/IP Address

How to connect to local host of another machine with android emulator

I am developing an app for android (with react-native) which is running in android studio emulator. This app should connect to a server, but I am in the testing phase and I run the server in a localhost port. but the localhost of another machine (which is in the same network that I am)
let's say the (local) IP of the other machine is 172.17.240.223 and the port which the server is running on is 8080
when I type 172.17.240.223:8080 in my browser (laptop browser), I get the response and there is no problem. Even when I type this in my browser in the emulator I get the response, but this won't happen in app. why is that?
More generally, it's not possible to customize the URL and how the bundle gets loaded. This flexibility is useful to have.
check issue on github here
in this case ,you can use testflight for IOS testing and for android just create apk.

Android Emulator: can't connect to server

I'm newbie in Android development so forgive me for a banal question
I'm in this situation: I have a server locate on IP address 192.168.11.188; this server sends a JMS message by using MQTT protocol
On my laptop I'm using paho as MQTT messages consumer
I'm building an Android app and I test it by using the emulator
I have the following problem: if i test everything in local by configuring the APP to connect to the JMS server on my laptop and specifying the IP address 10.0.2.2 all works pretty good
When i configure the APP in order to connect to the server on IP address 192.168.11.188 it can't connect (I tried by using telnet and I can confirm that server is alive and active)
Moreover in the sent MQTT message I have a URL that points to a my site. The URL is like: http://192.168.11.188:8080/.....
Well inside the emulator i can't open the URL; I get the error "net::ERR_CONNECTION_REFUSED" (but I'm sure the server is active)
I attach an image showing the error
I'm struggling on this problem from some days...
I'm sure I'm missing something but I can't figure what I'm missing
How can I configure correctly the emulator in order to connect to the server on the the IP 192.168.11.188 and open web pages always from this IP?
thank you
Angelo

Ionic can't run my app from the device browser

I am developing an Android app using ionic. When I execute ionic serve I can see my app on my computer through http://localhost:8100
I checked my ip address using ipconfig and it's 192.168.0.3, so I tried using this IP from my device (http://192.168.0.3:8100), but I got a 404. I then tried from the very same computer I am developing from, and I got a 404 too!
Funny thing is, ionic uses two servers:
If I put http://192.168.0.3:35729 I can see live reload server both from my computer and my device. I didn't have to touch anything on my router to forward ports, and both my computer and my phone are on the same network. Note that I cannot access http://192.168.0.3:8100 neither from my phone nor from my computer (the same one I am using to develop)
Also I am serving a REST web service on 8080 from a J2EE app, and I can see it in my device. My app consumes this service, and from the computer, everything works fine. But from the device, although I can use the phone browser to access the REST server, my ionic app gives me another 404 error!
Can anyone point me in the right direction?
You will have to change the address Ionic has configured. Run:
ionic address
Then it will provide you a list of available addresses:
Multiple addresses available.
Please select which address to use by entering its number from the list below:
1) 192.168.0.107 (eth1)
2) localhost
Select your local IP from the available options. This must solve the issue you're facing.

Android:Socket programming between phone and system

I am trying to write a client server application, in which the client is a android device.
I am not confident on socket programming.
I have written a server side application and a client side that runs on my emulator.
Will the same application work between a real android device?
I have edited your question (once its reviewed it will show up). From what I understand, your question is generic. It works on my emulator, will it work on my device.
The answer is yes. The emulator connects to 10.0.2.2 which redirects to 127.0.0.1 on your host machine right ? This is how you would have got it working.
To get it working from a device you will need to do the following
Load your java server on your real ip address on your desktop
Ensure that your desktop is on the internet and the ip address visible to the internet (open)
Ensure that your android phone points to the public ip address of your desktop.
Now, I know your worry :) open ip address. So, you can use a ec2 (free amazon ubuntu instance), install java on it and run your server as java -jar . From eclipse you can export a jar file (runnable jar file) with lib in your jarfilename_lib path.
You can use spring For android via HTTP request.
Here is an example.
When you have static ip in server you should set that static ip in your actual device.If you are running your app on emulator you must set 10.0.0.2.

Categories

Resources