When using my app on ics, after I change my wifi network from networkA to networkB all the requests for images start coming back with an exception.
failed with exception
> 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)
The strangest thing is that even uninstalling the app and reinstalling it wont fix it, just turning the phone off and on.
I saw a similar problem here http://groups.google.com/group/newsrob/browse_thread/thread/ea2f26d9d1753b79/5800e268eeab399c#5800e268eeab399c . The problem is not happening on phones with 4.0.3, just on the ones with 4.0.1, and the update doesnt seem to be available in Europe yet.
Maybe it's taking a while for the switch over to take place for some reason? You can check to see if there is an active network connection before making the request:
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();
}