# Java client hangs

**URL:** <https://discuss.elastic.co/t/java-client-hangs/309152>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 7, 2022, 7:38pm UTC](https://discuss.elastic.co/t/java-client-hangs/309152 "2022-07-07T19:38:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John16](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@John16](https://discuss.elastic.co/u/John16)\
**Post date:** [July 7, 2022, 7:38pm UTC](https://discuss.elastic.co/t/java-client-hangs/309152/1 "2022-07-07T19:38:20Z")

</div>

Hello!

I am writing a Java program to work with Elasticsearch server.  
My Java client version is 7.17.4, server version is 7.17.0.  
Consider the following code:

```auto
RestClient restClient = RestClient.builder(new HttpHost("host.org", 9200, "https")).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchIndicesClient indicesClient = new ElasticsearchIndicesClient(transport);
indicesClient.delete(b -> b.index("non-existent-index"));

```

I see the following exception on console (pretty valid):

```auto
Exception in thread "main" co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.delete] failed: [index_not_found_exception] no such index [non-existent-index]
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:281)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.delete(ElasticsearchIndicesClient.java:382)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.delete(ElasticsearchIndicesClient.java:398)

```

but the program hungs forever.

Why?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [July 7, 2022, 7:57pm UTC](https://discuss.elastic.co/t/java-client-hangs/309152/2 "2022-07-07T19:57:39Z")

</div>

You have to call `transport.close()`: the http client internally contains a pool of open connections and associated threads.

---

<div class="post-metadata">

**Author:** ![John16](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@John16](https://discuss.elastic.co/u/John16)\
**Post date:** [July 7, 2022, 8:04pm UTC](https://discuss.elastic.co/t/java-client-hangs/309152/3 "2022-07-07T20:04:21Z")

</div>

Indeed, thanks a lot!

---

<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:** [August 4, 2022, 8:04pm UTC](https://discuss.elastic.co/t/java-client-hangs/309152/4 "2022-08-04T20:04:22Z")

</div>

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