Skip to content

Commit

Permalink
[DOCS] Add transport.close() to connecting page
Browse files Browse the repository at this point in the history
Without this line, the code hangs because the HttpClient thread keeps
running indefinitely.
  • Loading branch information
pquentin committed May 15, 2024
1 parent 64ec619 commit f64799c
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 f64799c

Please sign in to comment.