Because network connections can be unstable and slow,
the Algolia API clients have pre-configured timeouts.
Not all timeouts are configurable in every API client.
Examples
C#
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
var configuration = new SearchConfig ( "YourApplicationID" , "YourWriteAPIKey" )
{
ConnectTimeout = 15 , // (Default) connection timeout in seconds
ReadTimeout = 5 , // (Default) read timeout in seconds
WriteTimeout = 30 , // (Default) write timeout in seconds
HostDownDelay = 300 //
};
config := search . Configuration {
AppID : "YourApplicationID" ,
APIKey : "YourWriteAPIKey" ,
ReadTimeout : 5 * time . Second , // (Default) read timeout in seconds
WriteTimeout : 30 * time . Second , // (Default) write timeout in seconds
HostDownDelay : 5 * 60 * time . Second // (Default) delay before retrying an unavailable host, in seconds
}
client := search . NewClientWithConfig ( config )
SearchConfig configuration =
new SearchConfig. Builder ( "YourApplicationID" , "YourWriteAPIKey" )
. setConnectTimeOut ( 2000 ) // (Default) connection timeout in milliseconds
. setReadTimeOut ( 5000 ) // (Default) read timeout in milliseconds
. setWriteTimeOut ( 30000 ) // (Default) write timeout in milliseconds
. setHostDownDelay ( 300000 ) // (Default) delay before retrying an unavailable host, in milliseconds
. build ();
SearchClient client = DefaultSearchClient . create (configuration);
const client = algoliasearch ( appId , apiKey , {
timeouts: {
connect: 2 , // (Default) connection timeout in seconds
read: 5 , // (Default) read timeout in seconds
write: 30 , // (Default) write timeout in seconds
},
});
const analytics = client . initAnalytics ({
timeouts: {
connect: 2 , // (Default) connection timeout in seconds
read: 5 , // (Default) read timeout in seconds
write: 30 , // (Default) write timeout in seconds
},
});
const personalization = client . initPersonalization ({
timeouts: {
connect: 2 , // (Default) connection timeout in seconds
read: 5 , // (Default) read timeout in seconds
write: 30 , // (Default) write timeout in seconds
},
});
val configuration = ConfigurationSearch (
applicationID = ApplicationID ( "YourApplicationID" ),
apiKey = APIKey ( "YourWriteAPIKey" ),
readTimeout = 50 , // (Default) read timeout in seconds
writeTimeout = 30 // (Default) write timeout in seconds
)
ClientSearch (configuration)
$config = SearchConfig :: create ( 'YourApplicationID' , 'YourWriteAPIKey' );
$config -> setConnectTimeout ( 2 ); // (Default) connection timeout in seconds
$config -> setReadTimeout ( 30 ); // (Default) read timeout in seconds
$config -> setWriteTimeout ( 30 ); // (Default) write timeout in seconds
SearchClient :: createWithConfig ( $config );
config = SearchConfig( "YourApplicationID" , "YourWriteAPIKey" )
config.connect_timeout = 2 # (Default) connection timeout in seconds
config.read_timeout = 5 # (Default) read timeout in seconds
config.write_timeout = 30 # (Default) write timeout in seconds
client = SearchClient.create_with_config(config)
config = Algolia :: Search :: Config . new (
{
application_id: "YourApplicationID" ,
api_key: "YourWriteAPIKey" ,
# (Default) read timeout in seconds
read_timeout: 30 ,
# (Default) write timeout in seconds
write_timeout: 30 ,
# (Default) connection timeout in seconds
connect_timeout: 2
}
)
client = Algolia :: Search :: Client . create_with_config (config)
val configuration = AlgoliaClientConfiguration (
httpConnectTimeoutMs = 2 * 1000 , // (Default) connection timeout in milliseconds
httpReadTimeoutMs = 2 * 1000 , // (Default) read timeout in milliseconds
httpRequestTimeoutMs = 2 * 1000 , // Write timeout in milliseconds
dnsTimeoutMs = 2 * 100 , // (Default) DNS connection timeout in milliseconds
hostDownTimeoutMs = 5 * 60 * 1000 // (Default) delay before retrying an unavailable host, in milliseconds
)
new AlgoliaClient (applicationId, apiKey, configuration = configuration)
let configuration = SearchConfiguration ( applicationID : "YourApplicationID" , apiKey : "YourWriteAPIKey" )
. set (\. readTimeout , to : 5 ) // (Default) read timeout in seconds
. set (\. writeTimeout , to : 30 ) // (Default) write timeout in seconds
let client = SearchClient ( configuration : configuration)
Parameters
Timeout for the TCP session to connect. Available in all clients except Swift, C#, Go, and Kotlin, Default values:
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:
The expected time for an unavailable host to become available.
Affects the time between API client retries. Only available for C#, Java, Go, and Scala. Default values:
C#, Java, Go, and Scala: 5 minutes
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
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’s no default value.
Same as #, but applies only to search operations. Only available for Swift. Default values:
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