连接失败:ECONNREFUSED [英] connect failed: ECONNREFUSED
问题描述
但是我得到:
detailMessage无法连接到localhost / 127.0.0.1(端口8080):connect失败:ECONNREFUSED(拒绝连接)(id = 830021648792)
本教程的全部代码在这里< a href =http://veereshr.com/Android/AndroidToServlet =nofollow noreferrer>链接
发生错误:
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
我检查了:
- 防火墙已禁用
- ping正在工作
- 连接字符串与从服务器管理界面运行servlet完全一样 -
http:// localhost:8080 / Requestor / RQSRV
- servlet正在运行
我的配置:
- 服务器:Glass Fish 4.0
- Android应用程序 - 在Eclipse中开发
- Servlet - 在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
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 running
My configuration :
- Server : Glass Fish 4.0
- Android App - Developed in Eclipse
- Servlet - Developed in NetBeans
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: http://developer.android.com/tools/devices/emulator.html#networkaddresses
For Genymotion use: 10.0.3.2 instead of 10.0.2.2
这篇关于连接失败:ECONNREFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!