Question

I'm writing an app that needs to be able to access the web server on my laptop. The phone I'm developing on is acting as a WiFi hotspot which my laptop is connected to. Everything is working fine if I try to access 192.168.43.16 in the phone's browser.

But the app I'm developing is not able to access the webserver for some reason. I'm guessing it's trying to use the 3G connection instead, which of course will not work. If I turn off mobile data I get an error message in my app saying that it can't connect to 172.30.253.241:8799, which seems to be my ISP's MMS server (?). That makes no sense to me, but maybe there's some caching going on here? Again, accessing my local webserver with Chrome in the phone works perfectly fine.

The app is using the "Android Asynchronous Http Client" by loopj, which is built on top of Apache's HttpClient. What can I do to make this work?

The reason I want to be able to access the local webserver is because it makes developing and debugging the server api used with my app a lot easier and faster than FTP-ing to my production server on the web.

Was it helpful?

Solution

Problem solved!

What I had to do was set the proxy of the AsyncHttpClient, using setProxy(), before making the request. I set the proxy address to the local IP address of my laptop running the web server.

client.setProxy("192.168.43.16", 80);

Now it seems to be working as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top