# How to close response or connection properly of RestClient

**URL:** <https://discuss.elastic.co/t/how-to-close-response-or-connection-properly-of-restclient/198760>\
**Category:** Elasticsearch\
**Created:** [September 9, 2019, 5:59pm UTC](https://discuss.elastic.co/t/how-to-close-response-or-connection-properly-of-restclient/198760 "2019-09-09T17:59:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekotqryz](https://avatars.discourse-cdn.com/v4/letter/e/82dd89/32.png) [@ekotqryz](https://discuss.elastic.co/u/ekotqryz)\
**Post date:** [September 9, 2019, 5:59pm UTC](https://discuss.elastic.co/t/how-to-close-response-or-connection-properly-of-restclient/198760/1 "2019-09-09T17:59:05Z")

</div>

From the document [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-low-usage-initialization.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-low-usage-initialization.html), we know that we should use one instance of RestClient for the whold application, and `close()` RestClient if we shutdown application .

but i have some question about each request, do we need to close every request properly, such as call `EntityUtils.consume(entity)`?

and do we need to consider to put connection back to internal conntion pool (httpasynclient)and how to ?

thanks

---

<div class="post-metadata">

**Author:** ![ekotqryz](https://avatars.discourse-cdn.com/v4/letter/e/82dd89/32.png) [@ekotqryz](https://discuss.elastic.co/u/ekotqryz)\
**Post date:** [September 11, 2019, 3:28pm UTC](https://discuss.elastic.co/t/how-to-close-response-or-connection-properly-of-restclient/198760/2 "2019-09-11T15:28:25Z")

</div>

Hi, anybody who knows this ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 9, 2019, 3:28pm UTC](https://discuss.elastic.co/t/how-to-close-response-or-connection-properly-of-restclient/198760/3 "2019-10-09T15:28:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
