Skip to content

Commit 57e18a1

Browse files
committed
Add section for closing the client connection
I could not find this anywhere in the JavaScript client docs, and I think it's worth a mention here
1 parent 4269197 commit 57e18a1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/connecting.asciidoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This page contains the information you need to connect and use the Client with
1313
* <<client-error-handling, Handling errors>>
1414
* <<keep-alive, Keep-alive connections>>
1515
* <<product-check, Automatic product check>>
16+
* <<closing, Closing the client>>
1617

1718
[[authentication]]
1819
[discrete]
@@ -691,6 +692,23 @@ const client = new Client({
691692
})
692693
----
693694

695+
[discrete]
696+
[[close-connection]]
697+
=== Close connection
698+
699+
If you want to end a connection to an Elasticsearch server, use the `close()` function.
700+
701+
[source,js]
702+
----
703+
const client = new Client({
704+
node: 'http://localhost:9200'
705+
});
706+
// ... do various queries
707+
client.close();
708+
----
709+
710+
711+
694712
[discrete]
695713
[[product-check]]
696714
=== Automatic product check
@@ -702,3 +720,4 @@ be sent to the server as part of the request pipeline before the main API call i
702720
In most cases, this will succeed during the very first API call that the client sends.
703721
Once the product check completes, no further product check HTTP requests are sent for
704722
subsequent API calls.
723+

0 commit comments

Comments
 (0)