In my application i wrote code for connecting to the URL like below
InputStream inputStream = new URL(url).openStream();
i got the erro
Also, I had the case that you are passing a wrong url, and the app is looking to retrieve the data, but never finds it. Check your url, maybe if you correct it, just in case that it would be wrong, then the request would not throws you that error.
This is happening because some times your server is taking too long to respond. Actually this could also happening due to a slow network, so you don't have full control over it. If you were using HttpClient, you could increase the timeout period:
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParameters, WAIT_RESPONSE_TIMEOUT);
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
client = new DefaultHttpClient(httpParameters);
CONNECTION_TIMEOUT
is the time to wait for a connection to establish. WAIT_RESPONSE_TIMEOUT
is the time to wait for data to be received - in your case this is what you need to increase.
Bottom line: