This documentation contains work-in-progress information for future Elastic Stack and Cloud releases. Use the version selector to view supported release docs. It also contains some Elastic Cloud serverless information. Check out our serverless docs for more details.
Timeout best practices
editTimeout best practices
editThis 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 Elasticsearch, raising a TimeoutError
when that time period has elapsed without receiving a response. However, Elasticsearch will always eventually respond to any request, even if it takes several minutes. The official Elasticsearch recommendation is to disable response timeouts entirely by default.
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:
-
Ensure keep-alive is enabled; this is the default, so no settings need to be changed, unless you have set
agent
tofalse
or provided an alternateagent
that disables keep-alive -
If using the default
UndiciConnection
, disable request timeouts by settingtimeout
to0
-
If using the legacy
HttpConnection
, settimeout
to a very large number (e.g.86400000
, or one day)