In my application i wrote code for connecting to the URL like below
InputStream inputStream = new URL(url).openStream();
i got the erro
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: