Android.system.ErrnoException:isConnected失败:ECONNREFUSED(拒绝连接) [英] Android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)

查看:6666
本文介绍了Android.system.ErrnoException:isConnected失败:ECONNREFUSED(拒绝连接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java连接MySQL和Json将数据发送到android,当我通过URL地址从Java发送数据到json时:

Im using Java connect with MySQL and Json will send data to android, When I send data from Java to json by URL address:

http://192.168.1.221:9999/rentalcar_service/category/getAllManufacturer

一切都很好,但是当我在Android中解析数据时,我收到了一个错误结果,如下所示:

everything's fine, but when I parse data in Android I received an error result following as:

private static final String URL_MANUFACTURERS = "http://192.168.1.221:9999/rentalcar_service/category/getAllManufacturer";

Logcat:

W/System.err: Caused by: android.system.ErrnoException: isConnected failed:    ECONNREFUSED (Connection refused)
W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:223)
W/System.err:   ... 25 more
I/MemoryCache: cache size=0 length=4
W/System.err: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 9999) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:234)
W/System.err:     at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:122)

(192.168.1.221)IP地址是我的电脑,如果我从192.168.1.221更改为localhost,我仍然收到同样的错误。

(192.168.1.221) IP address is my PC, if I change from 192.168.1.221 to localhost, I still receive same error.

如何解决这个问题?非常感谢!

How to fix this problem? Thank so much !

推荐答案

ECONNREFUSED表示尝试连接且远程主机端口未侦听。
因此可能是因为:

ECONNREFUSED means that the connection was attempted and the remote host port is not listening. Hence this can be caused because of:

它是否是有效的IP?使用ifconfig或ipconfig检查。
u可以尝试ping服务器。

Is it a valid IP? check using ifconfig or ipconfig. u can try pinging the server.

有关错误的详细信息可以从这里理解:
https://android.googlesource.com/platform /libcore/+/jb-mr2-release/luni/src/main/java/libcore/io/ErrnoException.java
https://developer.android.com/reference/android/system/ErrnoException.html

Details regarding the error can be understood from here: https://android.googlesource.com/platform/libcore/+/jb-mr2-release/luni/src/main/java/libcore/io/ErrnoException.java https://developer.android.com/reference/android/system/ErrnoException.html

这篇关于Android.system.ErrnoException:isConnected失败:ECONNREFUSED(拒绝连接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆