Skip to content

Commit 9d08422

Browse files
JoshMockgithub-actions[bot]
authored andcommitted
Add doc about timeout best practices (#2381)
(cherry picked from commit e9fdcb0)
1 parent fceebae commit 9d08422

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/configuration.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
== Configuration
33

44

5-
The client is designed to be easily configured for your needs. In the following
5+
The client is designed to be easily configured for your needs. In the following
66
section, you can see the possible options that you can use to configure it.
77

88
* <<basic-config>>
99
* <<advanced-config>>
10+
* <<timeout-best-practices>>
1011
* <<child>>
1112
* <<client-testing>>

docs/index.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ include::reference.asciidoc[]
2121
include::examples/index.asciidoc[]
2222
include::helpers.asciidoc[]
2323
include::redirects.asciidoc[]
24+
include::timeout-best-practices.asciidoc[]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[timeout-best-practices]]
2+
=== Timeout best practices
3+
4+
This client is configured by default to operate like many HTTP client libraries do, by using a relatively short (30 second) timeout on all requests sent to {es}, raising a `TimeoutError` when that time period has elapsed without receiving a response. However, {es} will always eventually respond to any request, even if it takes several minutes. The {ref}/modules-network.html#_http_client_configuration[official {es} recommendation] is to disable response timeouts entirely by default.
5+
6+
Since changing this default would be a breaking change, we won't do that until the next major release. In the meantime, here is our recommendation for properly configuring your client:
7+
8+
* Ensure keep-alive is enabled; this is the default, so no settings need to be changed, unless you have set `agent` to `false` or provided an alternate `agent` that disables keep-alive
9+
* If using the default `UndiciConnection`, disable request timeouts by setting `timeout` to `0`
10+
* If using the legacy `HttpConnection`, set `timeout` to a very large number (e.g. `86400000`, or one day)

0 commit comments

Comments
 (0)