title: Axis2 what is the correct way to set connection timeout and so timeout
body: <p>I have a Java program which use Axis2 for consuming a web service. Now I want to set connection timeout and socket timeout for that client.</p>
  
  <p>I have searched and found that there are two possible ways to do that.</p>
  
  <p><strong>1st method</strong></p>
  
  <p><a href="https://singztechmusings.wordpress.com/2011/05/07/how-to-configure-timeout-duration-at-client-side-for-axis2-web-services/" rel="nofollow noreferrer">https://singztechmusings.wordpress.com/2011/05/07/how-to-configure-timeout-duration-at-client-side-for-axis2-web-services/</a></p>
  
  <pre><code>stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeOutInMilliSeconds));
  stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));
  </code></pre>
  
  <p><strong>2nd method</strong></p>
  
  <p><a href="https://community.emc.com/docs/DOC-44893" rel="nofollow noreferrer">https://community.emc.com/docs/DOC-44893</a></p>
  
  <pre><code>MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
  HttpConnectionManagerParams params = new HttpConnectionManagerParams();
  params.setSoTimeout(timeOutInMilliSeconds);
  params.setConnectionTimeout(timeOutInMilliSeconds);
  multiThreadedHttpConnectionManager.setParams(params);
  HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
  stub._getServiceClient().getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
  </code></pre>
  
  <p>Does anyone know what is the difference between those two methods?</p>
  
  <p><strong>Edit</strong> : 
  Also I have found the following method which is used to set timeout. Confusion at it's best. :(</p>
  
  <pre><code>stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(180000); 
  </code></pre>