Skip to content

Commit

Permalink
[DOCS] Add transport.close() to connecting page (#807)
Browse files Browse the repository at this point in the history
* [DOCS] Add transport.close() to connecting page

Without this line, the code hangs because the HttpClient thread keeps
running indefinitely.

* Replace tabs with spaces
  • Loading branch information
pquentin authored May 16, 2024
1 parent 64ec619 commit 90292f2
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public void createClient() throws Exception {

// And create the API client
ElasticsearchClient esClient = new ElasticsearchClient(transport);

// Use the client...

// Close the transport, freeing the underlying thread
transport.close();
//end::create-client

//tag::first-request
Expand Down Expand Up @@ -115,6 +120,11 @@ restClient, new JacksonJsonpMapper(), null, esOtelInstrumentation

// And create the API client
ElasticsearchClient esClient = new ElasticsearchClient(transport);

// Use the client...

// Close the transport, freeing the underlying thread
transport.close();
//end::create-client-otel
}

Expand Down Expand Up @@ -150,6 +160,11 @@ AuthScope.ANY, new UsernamePasswordCredentials(login, password)
// Create the transport and the API client
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchClient client = new ElasticsearchClient(transport);

// Use the client...

// Close the transport, freeing the underlying thread
transport.close();
//end::create-secure-client-cert
}

Expand Down Expand Up @@ -185,6 +200,11 @@ AuthScope.ANY, new UsernamePasswordCredentials(login, password)
// Create the transport and the API client
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchClient client = new ElasticsearchClient(transport);

// Use the client...

// Close the transport, freeing the underlying thread
transport.close();
//end::create-secure-client-fingerprint
}

Expand Down

0 comments on commit 90292f2

Please sign in to comment.