Re: What is the relation between TIME_WAIT and HTTP Client calls to a RestService?

2015-06-05 Thread Oleg Kalnichevski
On Thu, 2015-06-04 at 15:32 -0700, Check Peck wrote:
 @Michael: Thanks for your suggestion. Can you explain me why do you think,
 it's a TCP issue? I was assuming may be the way I am using RestTemplate in
 my code might not be right and that's why it might be resulting in
 TIME_WAIT connections a lot on the machine where I have my code deployed
 which makes Http Call to my RestService? In the company I am working here,
 they have their own Parent POM in which they have spring dependency, the
 latest I can get for Spring is 3.2.8: I am not sure whether Spring 3.2.8
 uses new version of HttpClient or not. I did check the first github link
 you provided but I was not able to find ivy.xml file in 3.2.x branch so
 cannot confirm that. May be you know some other way to confirm that. I can
 use Spring 3.2.8 version max here. And also, do you see any issues with the
 way I am using RestTemplate here, I am just using default way of making
 HttpClient calls, may be I need to have some sort of extra parameter to
 resolve this issue? Are there anything I need to set while making
 RestTemplate calls like Connection: close or keep-alive anything like
 this? And also do you think the way I am using RestTemplate will reuse/pool
 my client connections or not?
 
 @Stefan: I am using RestTemplate in default way as shown in my above code.
 I am assuming, it will be reusing/pooling my connections right? I did
 google the issue and I found out lot of things, like lowering down the
 tcp_fin_timeout value from 60 to 30 and some other stuff as mentioned
 here in this article:
 
 http://www.fromdual.com/huge-amount-of-time-wait-connections
 
 But I was trying to confirm whether it might be related to how I am using
 RestTemplate or it is a OS issue? If I can confirm it's an OS issue, then I
 will look into that and if let's say the way I am using RestTemplate is not
 right, then I might try improving my code to see whether the problem goes
 away or not. I am thinking may be the way I am using RestTemplate is not
 right? May be I need to have keep-alive options on?
 

Connections in TIME_WAIT are perfectly normal depending on your OS
systems and do not represent an issue with HttpClient resource
management.

For details see
http://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions

Oleg 


 
 On Thu, Jun 4, 2015 at 12:52 PM, Stefan Magnus Landrø 
 stefan.lan...@gmail.com wrote:
 
  I presume you are reusing/pooling your client connections, right?
  Also - you could tune your OS to shutdown connections faster. You can
  easily google you issue.
 
  Stefan
 
  2015-06-04 17:51 GMT+02:00 Check Peck comptechge...@gmail.com:
 
   I am using Spring RestTemplate to make a HTTP Calls to my RestService. I
  am
   using spring framework 3.1.1 version of RestTemplate. I cannot upgrade
  this
   since that's what we are using in our company.
  
   Now machine which is running my code (which uses RestTemplate) to make
  call
   to my RestService, I see lot of TIME_WAIT connections opened on that
   particular machine?
  
   - Is there any reason why it happens with RestTemplate or the way I am
   using it?
   - Also, what is the connection between TIME_WAIT and HTTP Client calls to
   my RestService? I am not able to understand this as well. Does HTTP Calls
   has any significance on TIME_WAIT? There might be some theoretical
   explanation for this I guess.
  
   Below is how I am using RestTemplate in my code base:
  
   public class DataClient implements Client {
  
   private final RestTemplate restTemplate = new RestTemplate();
   private ExecutorService executor =
   Executors.newFixedThreadPool(10);
  
   // for synchronous call
   @Override
   public String getSyncData(DataKey key) {
   String response = null;
   FutureString handler = null;
   try {
   handler = getAsyncData(key);
   response = handler.get(key.getTimeout(),
   TimeUnit.MILLISECONDS);
   } catch (TimeoutException ex) {
   // log an exception
   handler.cancel(true);
   } catch (Exception ex) {
   // log an exception
   }
  
   return response;
   }
  
   // for asynchronous call
   @Override
   public FutureString getAsyncData(DataKey key) {
   FutureString future = null;
  
   try {
   Task task = new Task(key, restTemplate);
   future = executor.submit(task);
   } catch (Exception ex) {
   // log an exception
   }
  
   return future;
   }
   }
  
   And below is my simple Task class
  
   class Task implements CallableString {
  
   private final RestTemplate restTemplate;
   private final DataKey key;
  
   public Task(DataKey key, RestTemplate restTemplate) {
 

Re: [ANNOUNCEMENT] HttpComponents Client 4.5 GA Released

2015-06-05 Thread Shawn Heisey
On 6/5/2015 3:24 AM, Oleg Kalnichevski wrote:
 The Apache HttpComponents project is pleased to announce 4.5 GA release
 of HttpComponents HttpClient.

 HttpClient 4.5 (GA) is a minor feature release that includes several
 incremental enhancements to the existing functionality such as support
 for private domains in the Mozilla Public Suffix List.

 Users of HttpClient 4.x are advised to upgrade.

Will there be any other components with a 4.5 release, or just the
httpclient?  I'm specifically interested in httpcore and httpmime.

Thanks,
Shawn


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org