java - Apache HttpClient HttpRequestRetryHandler never invoked -


i'm using apache http commons defaulthttpclient , after construction, i'm setting retry handler:

 httpclient.sethttprequestretryhandler(new httprequestretryhandler() {                 @override                 public boolean retryrequest(final ioexception ioe,                         final int numretry, final httpcontext context)                 {                     log.d(tag, "retry handler received exception of type: " + ioe.getclass().getname() + ", num retries: " + numretry);                     if (numretry > 4) { // 3 retries                         return false;                     }                     // exceptions can retry without knowledge of methods being invoked                     if (ioe instanceof nohttpresponseexception                             || ioe instanceof unknownhostexception                             || ioe instanceof socketexception) {                     }                     return false;                 }         }); 

the server sending requests times out, , in catch of execute() call, receive io error, "the operation timed out" never see "retry handler received exception of type" log statement in console output. of requests post requests, idempotent--they're safe call multiple times without adverse side-effects.

am setting retry handler incorrectly? retry handler invoked in scenarios?

return true if handled exceptional case in handler.

that should keep exception beeing thrown.

also handle timeout exception in handler well.

httpclient.sethttprequestretryhandler(new httprequestretryhandler() {                 @override                 public boolean retryrequest(final ioexception ioe,                         final int numretry, final httpcontext context)                 {                     log.d(tag, "retry handler received exception of type: " + ioe.getclass().getname() + ", num retries: " + numretry);                     if (numretry > 4) { // 3 retries                         return false;                     }                     // exceptions can retry without knowledge of methods being invoked                     if (ioe instanceof nohttpresponseexception                             || ioe instanceof unknownhostexception                             || ioe instanceof socketexception                             // replace actual type of exception                             || ioe instanceof timeoutexception) {                                   return true;                     }                     return false;                 }         }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -