title: Getting SocketTimeOutException : read time out on rest calls to internal other micro spring boot service
body: <pre><code>Encountered Internal Server Exception
  org.springframework.web.client.ResourceAccessException: I/O error on GET request for "localhost:8034/v1/users/81ebc4ca-2496-4cc3-b533-311f237b6fe9/crop_details/10/summary": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:666)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:621)
      at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:321)
      at ...
      at java.lang.Thread.run(Thread.java:745)
  
  Caused by: java.net.SocketTimeoutException: Read timed out
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
      at java.net.SocketInputStream.read(SocketInputStream.java:170)
      at java.net.SocketInputStream.read(SocketInputStream.java:141)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
      at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
      at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:84)
      at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
      at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
      ... 91 common frames omitted
  </code></pre>
  
  <p><strong>Scenario</strong> - When I am trying to load testing using JMeter for Rest API from one service(running on 8033 port). It internally calls using RestTemplate to other service rest API(above one on 8034). For few request it works fine but as I go beyond just 10 concurrent requests it start giving above error. </p>
  
  <p><strong>What I tried till now</strong></p>
  
  <ul>
  <li>I already tried using Different ClientManagers to set both connection and read time out values.</li>
  <li>Also tried using PoolConnectionMangers. </li>
  <li>Custom Keep Alive Strategy.</li>
  <li>Setting JDK's values for above time out properties.</li>
  </ul>
  
  <p>But Still getting same problem.</p>
  
  <p><strong>Links referred</strong></p>
  
  <ul>
  <li><a href="http://www.baeldung.com/httpclient-connection-management" rel="nofollow noreferrer">http://www.baeldung.com/httpclient-connection-management</a></li>
  <li><a href="http://www.baeldung.com/rest-template" rel="nofollow noreferrer">http://www.baeldung.com/rest-template</a></li>
  <li>http:/blog.technogemsinc.com/2010/08/java-url-connection-timeout-default.html</li>
  </ul>
  
  <p>Same thing works on my local machine for 10000 request without any problem.</p>
  
  <p>Box/Server details - 3.7 GB/50GB single core CPU</p>