连接失败:ECONNREFUSED(connect failed: ECONNREFUSED)

系统教程 行业动态 更新时间:2024-06-14 16:57:17
连接失败:ECONNREFUSED(connect failed: ECONNREFUSED)

我正在开发一个应用程序,我想我想做的是从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 running

My 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

更多推荐

本文发布于:2023-04-12 19:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/26926654274c5b0f2f1ee1c946d080fe.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ECONNREFUSED   connect   failed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!