HttpURLConnection setReadTimeout is broken?
I am trying to develop something that can track an HTTP URL for availability.
I was almost ready to use Apache's http client library then I suddenly noticed that since 1.4 Java net API has setReadTimeout on HttpURLConnection
So I went ahead and built something that looks like this
HttpURLConnection httpConn = initHttpUrlConnection(); //initates connection to http url
OutputStream out = httpConn.getOutputStream();
LOGGER.info("Sent request to server");
int responseTimeOutSecs = 60 //will wait for 60 secs for response
httpConn.setConnectTimeout(responseTimeOutSecs * 1000);
httpConn.setReadTimeout(responseTimeOutSecs * 1000);
Now, as a test, I shut down the Server Application (not the app.server) that serves the page I am trying to read.
But the code just hangs at
InputStreamReader httpInputStreamReader =
Instead of throwing a SocketTimeoutException as explained in the JavaDoc.
Have you seen similar behavior?