Android 连接异常

发布于 2024-12-05 09:42:46 字数 1054 浏览 0 评论 0原文

当我尝试启动 url 连接时,收到一条奇怪的错误消息。 这是日志输出:

     E/admarvelservice( 2366): postString: &site_id=14488&partner_id=ef8a30b841b36346& timeout=5000&version=1.5&language=java&format=android&sdk_version=2.1.3&sdk_version_date=2011-08-08&device_model=Nexus+S&device_name=GRJ22&get_cached_ads=true&device_systemversion=2.3.5&resolution_width=480&max_image_width=480&resolution_height=800&max_image_height=800&device_os=Android&target_params=appv%3D%3ES%7C%7Cla%3D%3Ede%7C%7Cco%3D%3EAT%7C%7Cscreenorient%3D%3Ep%7C%7Cappvn%3D%3E3.4.0%252F%7C%7Cosv%3D%3E2.3.5

     D/admarvelservice( 2366): Error: java.net.ConnectException: ads.admarvel.com/127.0.0.1:80 - Connection refused

有人知道这里有什么问题吗? 谢谢。

编辑:我如何连接:

URL myURL;
try {
    myURL = new URL(_url);
    m_ucon = myURL.openConnection();
    m_ucon.setConnectTimeout(8000);

} catch (Exception e) {
e.printStackTrace();

}

有趣的是,连接正在工作,但每秒我的 logcat 都会喊出上面显示的错误消息。

i get a strange error message when i try to start an url connection.
here´s the log output:

     E/admarvelservice( 2366): postString: &site_id=14488&partner_id=ef8a30b841b36346& timeout=5000&version=1.5&language=java&format=android&sdk_version=2.1.3&sdk_version_date=2011-08-08&device_model=Nexus+S&device_name=GRJ22&get_cached_ads=true&device_systemversion=2.3.5&resolution_width=480&max_image_width=480&resolution_height=800&max_image_height=800&device_os=Android&target_params=appv%3D%3ES%7C%7Cla%3D%3Ede%7C%7Cco%3D%3EAT%7C%7Cscreenorient%3D%3Ep%7C%7Cappvn%3D%3E3.4.0%252F%7C%7Cosv%3D%3E2.3.5

     D/admarvelservice( 2366): Error: java.net.ConnectException: ads.admarvel.com/127.0.0.1:80 - Connection refused

anybody an idea whats the problem here?
thanks.

EDIT: how i connect:

URL myURL;
try {
    myURL = new URL(_url);
    m_ucon = myURL.openConnection();
    m_ucon.setConnectTimeout(8000);

} catch (Exception e) {
e.printStackTrace();

}

funny thing is that the connection is working, but every second my logcat shouts the errormessage shown above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

最好是你 2024-12-12 09:42:46

我认为这与你的申请无关。
广告服务 (admarvelservice) 是一个例外。

I think this has nothing to do with your application.
The exception comes from an Advertising Service (admarvelservice).

洛阳烟雨空心柳 2024-12-12 09:42:46

您正在使用广告拦截器应用程序并且安装了 Shazam。只需获取 Shazam 的付费版本、删除广告拦截器或忽略该错误即可。

You are using an adblocker app and you have Shazam installed. Just either get the paid version of Shazam, remove ad blocker or just ignore the error.

2024-12-12 09:42:46

首先在 AndroidManifest.xml 中检查这一点:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

本地主机 IP 地址是:127.0.0.1,因此您也可以通过此检查。

尝试使用此 http 连接:

public SomeClass {
    HTTTPUrlConnection conn = new HTTPUrlConnection(...);
    SomeClass instance = new SomeClass();

    private SomeClass() {}
    public static getInstance() {
       return instance;
    }
}

您应该尝试 Singleton 模式 进行请求响应。

Check this first in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Localhost ip address is: 127.0.0.1 so u can check by this too.

try with this http connection:

public SomeClass {
    HTTTPUrlConnection conn = new HTTPUrlConnection(...);
    SomeClass instance = new SomeClass();

    private SomeClass() {}
    public static getInstance() {
       return instance;
    }
}

you should try Singleton pattern for request response.

安稳善良 2024-12-12 09:42:46

您必须在 AndroidManifest.xml 中设置使用权限

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

You must set uses permission in the AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
孤寂小茶 2024-12-12 09:42:46

以我的经验来说

连接被拒绝

的原因是:

a|- 您无权访问,因为您可能位于代理下,并且需要凭据才能建立连接。

b|- 您需要在 AndroidManifest.xml 中添加连接权限:

<uses-permission android:name="android.permission.INTERNET" />

For my experience

Connection Refused

is caused by :

a|- You don´t have access because probably you are under a Proxy and you need credentials to establish a connection.

b|- You need to add the persmission for connection inside your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文