How to access local tomcat via HttpRequest from co

2019-09-20 07:01发布

While accessing from emulator works fine with:

  response = CustomHttpClient.executeHttpPost(
                "http://10.0.2.2:8080/DWAP/SERVLET", postParameters);

when I write from my Android device

 response = CustomHttpClient.executeHttpPost(
                "http://XX.XX.XX.XX:8080/DWAP/SERVLET", postParameters);

Where xx.xx.xx.xx is my public IP I do not get access to the local server.

Is there an easy way to test the app from an Android device to access the local Tomcat or do I need to test with emulator only?

Do need to go through port-fprwarding on my router or is there another way to connect "internally" on my WLAN. (Android mobile phone <-> MAC with local Tomcat)?

1条回答
贼婆χ
2楼-- · 2019-09-20 07:26

Try setting your computer as the DMZ of the router. This way, communication with your router (public ip) leads directly to your computer (local ip).

查看更多
登录 后发表回答