Android Emulator: can't connect to server - android

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

Related

API Calls connecting to intranet server not working in Android Emulator

I am trying to connect to the local intranet server from my android application. The api calls work fine in the postman and other clients. But, when I am trying to do the get or post request to the server from android emulator, it's returning response code "503" (meaning host is not reachable).
The APIs are hosted in the server system which is in the local network. I have tried adding proxy, DNS settings, still no use.
I am stuck on this issue since a week now.
It would be great if someone could help on this!
you need to set URL as 10.0.2.2:portNr
portNr = the given port by ASP.NET Development Server

How to connect to cakephp server with localhost:port from Android emulator?

I am running the cakephp built in server bin/cake server which works fine for making requests through my laptop's browser: localhost:8765/users/get/1.
Yet when I try through my Android emulator to reach 10.0.2.2:8765/users/get/1 it just returns 10.0.2.2 refused to connect.
If I turn off the cakephp server and use MAMP instead I can successfully reach my local server with 10.0.2.2:8888/ionic-backend/users/get/1. So I know my emulator is setup correctly but does anyone know how to connect using cakephp's server? It would be much more convenient.
I am using a Mac, if that helps.

Debugging an App, that needs a URL to a server

I have a Xamarin Solution with an Android, iOS, and Windows mobile solution. I also have a Web Server that sits on localhost:XXXX.
I need to be able to access the URI endpoints on my local, while debugging on Mobile.
While the Web Server is running I go to fiddler, and compose http://localhost:XXXX/api/Locationsand everything is correct, I get the JSON data and life is good.
However when debugging the App on any phone, I suspect the endpoint on the phone is trying to access it's own "localhost". Is there a hosts file that I can edit on the emulators? or another solution?
If you have WiFi, change localhost to your local IP address and connect phone to that WiFi

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

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).

Connect to GlassFish server using HttpURLConnection in Android

I am developing an Android application that accesses a remote server using HttpURLConnection.
The server was (and still is) developed using NetBeans so, when testing the server on my local machine, I run it using NetBeans and the built-in GlassFish server.
I have tried to connect to the running server in Eclipse using HttpURLConnection giving localhost as the server (with the socket) but keep getting Connection Refused.
I can still access the local server from my browser with no problem but can't get to it from Eclipse.
The code also works when copnnecting to the actual remote server.
I am not sure where to go next.
if i remember correctly, 10.0.2.2 is the IP Address you need for the app on the emulator to talk to your development machine. Yep. see http://developer.android.com/tools/devices/emulator.html ("Network Address Space")

Categories

Resources