0

I am using this to setup RestTemplate. https://howtodoinjava.com/spring-boot2/resttemplate/resttemplate-httpclient-java-config/

At first it is working fine, then after sometime I am getting Timeout waiting for connection from pool; nested exception is org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool

Stacktrace:

_targethost _targetip _loggername _subsystem _procid _threadid _userid _transactionid _messageid [ERROR] 2021-07-06 15:39:18,396 [http-nio-8080-exec-630] [28477] com.thechetankrishna.lookupService:502 - lookup Failed : I/O error on POST request for SOME_URL: Timeout waiting for connection from pool; nested exception is org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool

LMC
  • 10,453
  • 2
  • 27
  • 52
Chetan Krishna
  • 131
  • 1
  • 2
  • 8
  • can you please add the whole stacktrace? – Simon Martinelli Jul 07 '21 at 08:22
  • @SimonMartinelli _targethost _targetip _loggername _subsystem _procid _threadid _userid _transactionid _messageid [ERROR] 2021-07-06 15:39:18,396 [http-nio-8080-exec-630] [28477] com.thechetankrishna.lookupService:502 - lookup Failed : I/O error on POST request for http://SOME_URL: Timeout waiting for connection from pool; nested exception is org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool – Chetan Krishna Jul 07 '21 at 09:28
  • `Timeout waiting for connection from pool` all the connections in the pool are in use, it's overloaded or there's a [connection leak](https://stackoverflow.com/a/11893328/2834978). – LMC Jul 08 '21 at 03:06
  • Actually from what I know RestTemplate already closes the connection once done. If all the connections are in use then also new connection request should wait in a queue ? – Chetan Krishna Jul 08 '21 at 05:46
  • Yes. Look here to [enable logging](https://hc.apache.org/httpcomponents-client-4.5.x/logging.html) and here is some more info on [how it works](https://stackoverflow.com/questions/50890024/correct-way-to-implement-http-connection-pooling/50901789#50901789); – LMC Jul 09 '21 at 18:27

0 Answers0