Reputation: 20279
I want to connect to a server on my local network (10.134.0.178:80
). The ip address of my machine is 10.134.3.12
and the ip address of the emulator Wi-Fi is 192.168.232.2
.
Now I found out that you have to use 10.0.2.2
to connect to a server on your local machine. But the server isn't running on my local machine - instead it is a separate instace on my LAN.
My local machine can reach and ping the server without problems. The emulator not, but the emulator has internet access. So I can access e.g. www.google.com.
How can I connect the emulator with the server? The shown redirection rules only apply on port level. So how is this meant to be used? Other solutions only talk about a local server. Only one is talking about a similar case, but this is not working for me (no connection)
netsh interface portproxy add v4tov4 listenport=80 connectport=80 connectaddress=10.134.0.178
Additionally, I have to switch server instances (different ips/ports/addresses). So how can I use the Android Emulator in this case? To which address should the webservice calls be made? 10.0.2.2
or 10.134.0.178
?
Upvotes: 4
Views: 8136
Reputation: 20279
Don't know what the reason was, but the most plausible one is, that the server had a temporal issue. Now I can connect to my server without further changes!
One thing what still didn't work for me was ping
, but it is listed under Local networking limitations:
Depending on the environment, the emulator might not be able to support other protocols (such as ICMP, used for "ping"). Currently, the emulator does not support IGMP or multicast.
Upvotes: 0
Reputation: 31
Hmmm, well, your Android app should connect to the server's address/port as it appears to the host machine running the Android emulator. I have a web server on my LAN and my emulator can access it directly. Start with pointing Chrome in your emulator at a web server on your LAN (assuming you have one on there somewhere) - if the server is on 10.134.0.178:80 then just type 10.134.0.178 in to your Chrome address bar. If that's not working then you need to look and see what's stopping it - any redirection rules getting in the way?
Upvotes: 1