我正在开发一个应用程序,我想我想做的是从android中的服务器数据库接收数据。 所以我开始运行一些教程。 我发现一个正在做很多我想要的。 但我得到:
detailMessage "failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused)" (id=830021648792)本教程的全部代码在这里是链接
错误发生在:
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
我检查了:
防火墙被禁用 ping正在工作 连接字符串与从servlet运行servlet时完全一样 - server: http://localhost:8080/Requestor/RQSRV我的配置:
服务器:玻璃鱼4.0 Android应用程序 - 在Eclipse中开发 Servlet - 在NetBeans中开发I am developing one app, and what I think I wanna do is receive data from server database in android. So I started to run some tutorials. I found one that is doing pretty much what I want. But I am getting:
detailMessage "failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused)" (id=830021648792)Whole code of this tutorial is here link
Error occurs on :
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
I checked that:
firewall is disabled ping is working connection string is exactly the same as when I run the servlet from server admin interface - http://localhost:8080/Requestor/RQSRV -the servlet is runningMy configuration :
Server : Glass Fish 4.0 Android App - Developed in Eclipse Servlet - Developed in NetBeans最满意答案
要从Android模拟器访问您的PC localhost,请使用10.0.2.2而不是127.0.0.1。 localhost或127.0.0.1是指仿真设备本身,而不是仿真器正在运行的主机。
参考: http : //developer.android.com/tools/devices/emulator.html#networkaddresses
对于Genymotion使用: 10.0.3.2而不是10.0.2.2
To access your PC localhost from Android emulator, use 10.0.2.2 instead of 127.0.0.1. localhost or 127.0.0.1 refers to the emulated device itself, not the host the emulator is running on.
Reference: https://developer.android.com/studio/run/emulator-networking#networkaddresses
For Genymotion use: 10.0.3.2 instead of 10.0.2.2
更多推荐
发布评论