android 尝试连接到 gwt 页面时出现 HttpHostConnectException
android HttpHostConnectException while trying to connect to a gwt page
我写了一个已经可以运行的 gwt 项目。我遇到的唯一问题是,我无法使用自己编程的 android 应用程序连接到服务器。我可以轻松地使用浏览器在 http://127.0.0.1:8888 with the browser, but when i try to connect to a servlet that maps to http://127.0.0.1:8888/ip/ i get a HttpHostConnectException connection refused exception. i can access http://127.0.0.1:8888/ip/ 启动我的 gwt 页面,但不能使用我的 android 应用程序。这是我尝试连接到服务器的 android 代码
try{
HttpClient httpclient = new DefaultHttpClient();
ArrayList<NameValuePair> postParameters;
httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://127.0.0.1:8888/ip/");
...
execute = httpclient.execute(httpPost);
catch (Exception e) {
Log.e(TAG, e.getMessage(), e); // connection refused
}
当我尝试使用我的 android 应用程序 post 时,该 servlet(映射到 /ip/)的 doPost() 方法从未被调用。
相同的结构与我的 vaadin 和 jquery 项目完美配合。只是 gwt 造成了这个问题。
问题只存在于本地(很可能是因为超级开发模式)。将intellij idea调试配置中bindaddress中的ip从127.0.0.1替换为设备ip后,问题解决
我写了一个已经可以运行的 gwt 项目。我遇到的唯一问题是,我无法使用自己编程的 android 应用程序连接到服务器。我可以轻松地使用浏览器在 http://127.0.0.1:8888 with the browser, but when i try to connect to a servlet that maps to http://127.0.0.1:8888/ip/ i get a HttpHostConnectException connection refused exception. i can access http://127.0.0.1:8888/ip/ 启动我的 gwt 页面,但不能使用我的 android 应用程序。这是我尝试连接到服务器的 android 代码
try{
HttpClient httpclient = new DefaultHttpClient();
ArrayList<NameValuePair> postParameters;
httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://127.0.0.1:8888/ip/");
...
execute = httpclient.execute(httpPost);
catch (Exception e) {
Log.e(TAG, e.getMessage(), e); // connection refused
}
当我尝试使用我的 android 应用程序 post 时,该 servlet(映射到 /ip/)的 doPost() 方法从未被调用。
相同的结构与我的 vaadin 和 jquery 项目完美配合。只是 gwt 造成了这个问题。
问题只存在于本地(很可能是因为超级开发模式)。将intellij idea调试配置中bindaddress中的ip从127.0.0.1替换为设备ip后,问题解决