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

SearchClient::createWithConfig($config);

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

About this method # A

Change the pre-configured timeouts.

Because network connections can be unstable and slow, the Algolia API clients have pre-configured timeouts.

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

Examples # A

1
2
3
4
5
6
$config = SearchConfig::create('AJ0P3S7DWQ', '••••••••••••••••••••');
$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 # A

Parameter Description
connectTimeout #
type: integer
default: different for every client
Optional

Timeout for the TCP session to connect.

Available in all clients except Swift, C#, Go, and Kotlin.

Default values:

readTimeout #
type: integer
default: different for every client
Optional

Timeout for the read on the TCP socket.

Default values:

  • PHP, Ruby: 30 seconds
  • JavaScript, Python, Swift, C#, Java, and Go: 5 seconds
  • Scala: 2 seconds
  • Kotlin: 50 seconds
writeTimeout #
type: integer
default: 30 s
Optional

Same as requestTimeout, but applies only to write operations.

Available in all clients except Scala.

Default values:

  • PHP, Ruby, JavaScript, Python, Swift, C#, Java, Go, and Kotlin: 30 seconds
hostDownDelay #
type: integer
default: different for every client
Optional

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

Only available for C#, Java, Go, and Scala.

Default values:

  • C#, Java, Go, and Scala: 5 minutes
dnsTimeout #
type: integer
default: 200 ms
Optional

Timeout for the DNS resolution.

Only available for Scala. This timeout exists as connectTimeout in the other API Clients. If both connectTimeout and dnsTimeout are set, the smaller value of the two is used.

Default values:

  • Scala: 200 milliseconds
searchReadTimeout #
type: integer
default: 5 s
Optional

Same as requestTimeout, but applies only to search operations.

Only available for Swift.

Default values:

  • Swift: 5 seconds
requestTimeout #
type: integer
default: no default
Optional

HTTP timeout for the request.

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 # A

This method doesn't return a response.

Did you find this page helpful?
PHP v3