I have a web service that accepts a POST method with XML. Then it works fine, in some random case, it cannot contact the server, throwing an IOException with the message The target server failed to respond . Subsequent calls work fine.
This mainly happens when I make a few calls and then leave my application idle for about 10-15 minutes. The first call I make after this returns this error.
I tried a couple of things ...
I configure the retry handler as
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() { public boolean retryRequest(IOException e, int retryCount, HttpContext httpCtx) { if (retryCount >= 3){ Logger.warn(CALLER, "Maximum tries reached, exception would be thrown to outer block"); return false; } if (e instanceof org.apache.http.NoHttpResponseException){ Logger.warn(CALLER, "No response from server on "+retryCount+" call"); return true; } return false; } }; httpPost.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
but this retry was not called. (yes, I am using the correct instanceof clause). When debugging, this class is never called.
I even tried HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), false); up HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), false); but to no avail. Can someone tell me what I can do now?
IMPORTANT In addition to figuring out why I get the exception, one of the important issues I am facing is why the retryhandler does not work here?
Em Ae May 11 '12 at 21:19 2012-05-11 21:19
source share