java - Cannot set timeout on Resteasy Client on JBoss -


i trying create rest client on jboss eap server, , need make sure timeout end connection if gets stuck.

my code looks this:

int timeout = 5000; requestconfig defaultrequestconfig = requestconfig.custom().setconnectionrequesttimeout(timeout).setsockettimeout(timeout).setconnecttimeout(timeout).build(); httpclientbuilder builder = httpclientbuilder.create(); httpclient httpclient = builder.setdefaultrequestconfig(defaultrequestconfig).build(); // previous try // httpclients.custom().setdefaultrequestconfig(defaultrequestconfig).build();  clientexecutor executor = new apachehttpclient4executor(httpclient);          clientrequest cr = new clientrequest("http://www.someserviceurl.com/", executor); jsonobject jdata = new jsonobject();  jdata.put("param1", param1); jdata.put("param2", param2);  cr.accept("application/json"); cr.body("application/json", jdata.tostring());  clientresponse<string> cres = cr.post(string.class); 

currently code not timeout, gets stuck forever. doing wrong?

apparently known issue resteasy fixed on version 3.0.9.final.

you can see bug report here.

to fix it, upgrade resteasy or user deprecated defaulthttpclient:

defaulthttpclient httpclient = new defaulthttpclient(); httpparams params = httpclient.getparams(); httpconnectionparams.setconnectiontimeout(params, timeout); httpconnectionparams.setsotimeout(params, timeout); clientexecutor executor = new apachehttpclient4executor(httpclient);  clientrequest cr = new clientrequest("http://www.someserviceurl.com/", executor); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -