API Reference / API Methods / Advanced / Configuring timeouts

Configuring Timeouts

Required API Key: no ACL required
Method signature
$config = SearchConfig::create('YourApplicationID', 'YourAdminAPIKey');
$config->setConnectTimeout(integer connectTimeout);
$config->setReadTimeout(integer readTimeout);
$config->setWriteTimeout(integer writeTimeout);

SearchClient::createWithConfig($config);

About this method

You are currently reading the JavaScript API client v4 documentation. Check our migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You are currently reading the Ruby API client v2 documentation. Check our migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Override the pre-configured timeouts.

Network & DNS resolution can be slow. That is why we have pre-configured timeouts. We do not advise to change them, but it could make sense to change them in some special cases.

Note: Not all parameters are available for every language. See Parameters below.

Examples

1
2
3
4
5
6
$config = SearchConfig::create('YourApplicationID', 'YourAdminAPIKey');
$config->setConnectTimeout(2); // connection timeout in seconds
$config->setReadTimeout(30); // read timeout in seconds
$config->setWriteTimeout(30); // write timeout in seconds

SearchClient::createWithConfig($config);

Parameters

connectTimeout
type: integer
default: differs per client, see defaults below
Optional

Timeout for the TCP session to connect.

Note: Available in all languages except Swift, C#, and Kotlin.

Default values:

readTimeout
type: integer
default: differs per client, see defaults below
Optional

Timeout for the read on the TCP socket.

Default values:

  • PHP, Ruby, and Android: 30 seconds
  • JavaScript, Python, Swift, C#, Java, and Go: 5 seconds
  • Scala: 2 seconds
  • Kotlin: 50 seconds
writeTimeout
type: integer
default: differs per client, see defaults below
Optional

Same as requestTimeout, but applies only to write operations.

Note: Available in all languages except Android and Scala.

Default values:

  • PHP, Ruby, JavaScript, Python, Swift, C#, Java, Go, and Kotlin: 30 seconds
hostDownDelay
type: integer
default: differs per client, see defaults below
Optional

The expected period of time for a down host to get back up again. Impacts the time between API Client retries.

Note: Only available for Android, C#, Java, Go, and Scala.

Default values:

  • Android, C#, Java, Go, and Scala: 5 minutes
dnsTimeout
type: integer
default: differs per client, see defaults below
Optional

Timeout for the dns resolution.

Note: Only available for Scala. This timeout exists as connectTimeout in the other clients. If both connectTimeout and dnsTimeout are set, we use the smallest value of the two.

Default values:

  • Scala: 200 milliseconds
searchReadTimeout
type: integer
default: differs per client, see defaults below
Optional

Same as requestTimeout, but applies only to search operations.

Note: Only available for Swift.

Default values:

  • Swift: 5 seconds
requestTimeout
type: integer
default: differs per client, see defaults below
Optional

HTTP timeout for the request.

Note: Only available for Scala.

Default values: This timeout allows you to configure a global timeout that supersedes all other timeouts. Since it affects all different timeouts, there is no default value.

Response

No response

Did you find this page helpful?