gpt4 book ai didi

android - ErrnoException : isConnected failed: EHOSTUNREACH (No route to host) when changing the wifi network using ICS

转载 作者:IT老高 更新时间:2023-10-28 23:01:11 25 4
gpt4 key购买 nike

在 ics 上使用我的应用时,在我将 wifi 网络从 networkA 更改为 networkB 后,所有对图像的请求都开始返回异常。

异常失败

> org.apache.http.conn.HttpHostConnectException: Connection to
> https://m1.testapp.com refused at
> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
> at
> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
> at
> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
> at
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
> at
> com.testApp.android.ws.PooledRequestProcessor$Runner.run(PooledRequestProcessor.java:298)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> at java.lang.Thread.run(Thread.java:856) Caused by:
> java.net.ConnectException: failed to connect to /109.233.153.38 (port
> 443) after 20000ms: isConnected failed: EHOSTUNREACH (No route to
> host) at
> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:181)
> ... 10 more Caused by: java.net.SocketException: failed to connect
> to /109.233.153.38 (port 443) after 20000ms: isConnected failed:
> EHOSTUNREACH (No route to host) at
> libcore.io.IoBridge.isConnected(IoBridge.java:220) at
> libcore.io.IoBridge.connectErrno(IoBridge.java:152) at
> libcore.io.IoBridge.connect(IoBridge.java:112) at
> java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) at
> java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) at
> java.net.Socket.connect(Socket.java:842) at
> org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
> at
> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
> ... 10 more Caused by: libcore.io.ErrnoException: isConnected
> failed: EHOSTUNREACH (No route to host) at
> libcore.io.IoBridge.isConnected(IoBridge.java:201)

最奇怪的是,即使卸载应用程序并重新安装它也无法解决问题,只需关闭手机然后再打开即可。

我在这里看到了类似的问题 http://groups.google.com/group/newsrob/browse_thread/thread/ea2f26d9d1753b79/5800e268eeab399c#5800e268eeab399c . 4.0.3 的手机没有出现此问题,仅出现在 4.0.1 的手机上,而且该更新似乎还没有在欧洲推出。

最佳答案

也许由于某种原因需要一段时间才能进行切换?您可以在发出请求之前检查是否有 Activity 的网络连接:

ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

if (networkInfo != null && networkInfo.isConnected() && networkInfo.isAvailable())
{
// DO WHAT YOU NEED TO DO ON THE NETWORK
}
else
{
// PROMPT USER THAT NETWORK IS DISCONNECTED

Toast.makeText(this, "There is no active network connection!", 5000).show();
}

关于android - ErrnoException : isConnected failed: EHOSTUNREACH (No route to host) when changing the wifi network using ICS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8787285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com