# Elasticsearch Java API async/sync calls timeout issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-api-async-sync-calls-timeout-issue/286112>\
**Category:** Elasticsearch\
**Tags:** language-clients, async-search\
**Created:** [October 7, 2021, 9:41am UTC](https://discuss.elastic.co/t/elasticsearch-java-api-async-sync-calls-timeout-issue/286112 "2021-10-07T09:41:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkulyk](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pkulyk](https://discuss.elastic.co/u/pkulyk)\
**Post date:** [October 7, 2021, 9:41am UTC](https://discuss.elastic.co/t/elasticsearch-java-api-async-sync-calls-timeout-issue/286112/1 "2021-10-07T09:41:19Z")

</div>

Hi all!

I have a question regarding some king of locking in ES (Java API). There should be one async call that start a process and send a response to user that process is in on progress, but all other method can be not async, because code are not overloaded by listeners for all async calls. Anyways, I faced with next problem: I make async call to create a new index. In responce handler I called another method to add some documents (10 documents) to this index (this call is not an async one), but I always get `ava.io.IOException: listener timeout after waiting for [90000] ms` . But document actually were added... Also I noticed that if all the calls are async - there is not such problem.The same situation when all call are NOT async.

Elasticsearch version - 7.7.0

How it could be solved?

Here is a short example of a structure:

> **Summary**
>
> ```
> private void createIndex() throws IOException {
> ...
> restHighLevelClient.indices().createAsync(request, RequestOptions.DEFAULT, createIndexListener);
> ...
> }
> 
> ActionListener<CreateIndexResponse> createIndexListener = new ActionListener<CreateIndexResponse>() {
> 
> @Override
> public void onResponse(CreateIndexResponse createIndexResponse) 
> startProcess(createIndexResponse.index());
> }
> 
> @Override
> public void onFailure(Exception e) {
> ...
> }
> };
> 
> private void startProcess(){
> ...
> BulkRequest request = prepareBulkRequest(new BulkRequest(), newIndexName, preparedDocuments);
> BulkResponse bulk = restHighLevelClient.bulk(request, RequestOptions.DEFAULT); <---- and this call returns an IOException.
> ...
> }
> 
> ```

---

<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:** [November 4, 2021, 9:42am UTC](https://discuss.elastic.co/t/elasticsearch-java-api-async-sync-calls-timeout-issue/286112/2 "2021-11-04T09:42:12Z")

</div>

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