I am making a service request to a server using HttpsURLConnection like the code below :
URL url = new URL("service/url");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setConnectionTimeout(300000);
connection.setReadTimeout(300000);
parse (connection.getInputStream());
Service sometimes may take longer time, so ideally I should expect a TimeOut Exception but instead the client is making a retry and sending the same request again. Is there a way to explicitly disable any kind of retries? And I am not even sure if the set timeout methods are making any difference.
I am using Java 1.6
UPDATE
I tried connect() and getResponseCode() instead of getInputStream() but same behaviour:
URL url = new URL("service/url");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setConnectionTimeout(300000);
connection.setReadTimeout(300000);
connection.connect();
connection.getResponseCode();
even this is making 2 requests.
UPDATE
HttpClient fixed the issue. In HttpClient you can explicitly set retry to false