Api clients / Ruby / V1 / Methods

Configuring Timeouts | Ruby API Client V1 (Deprecated)

This version of the Ruby API client has been deprecated in favor of the latest version of the Ruby API client.

Required API Key: no ACL required
Method signature
Algolia::Client.new({
  application_id: 'YourApplicationID',
  api_key: 'YourWriteAPIKey',
  connect_timeout: Integer connectTimeout,
  send_timeout: Integer requestTimeout,
  receive_timeout: Integer readTimeout,
  batch_timeout: Integer searchBatchTimeout,
  search_timeout: Integer searchReadTimeout
})

About this method

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', 'YourWriteAPIKey');
$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
searchBatchTimeout
type: integer
default: differs per client, see defaults below
Optional

Same as requestTimeout, but applies only to batch operations.

Note: Only available for Ruby.

Default values:

  • Ruby: 120 seconds
searchReadTimeout
type: integer
default: differs per client, see defaults below
Optional

Same as requestTimeout, but applies only to search operations.

Note: Only available for Ruby and Swift.

Default values:

  • Ruby and 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?