Skip to content

Timeouts and Reconnect Strategy

Valkey GLIDE allows you to configure timeout settings and reconnect strategies. These configurations can be applied through the client configuration parameters.

Configuration SettingDescriptionDefault Value
Request TimeoutThis specified timeout duration represents the period during which the client will await the completion of a request. This includes the process of sending the request, waiting for a response from the node(s), and any necessary reconnection or retry attempts. If a pending request exceeds the specified timeout, it will trigger a timeout error. If no timeout value is explicitly set, a default value will be employed.250 milliseconds
Connection TimeoutThe duration in milliseconds to wait for a TCP/TLS connection to complete. This applies both during initial client creation and any reconnection that may occur during request processing. A high connection timeout may lead to prolonged blocking of the entire command pipeline. This is configured via the advanced client configuration.2000 milliseconds
Reconnect StrategyThe reconnection strategy defines how and when reconnection attempts are made in the event of connection failures.Exponential backoff

Setting Request Timeout for Long-Running Commands

Section titled “Setting Request Timeout for Long-Running Commands”
from glide import (
GlideClusterClient,
GlideClusterClientConfiguration,
NodeAddress
)
addresses = [NodeAddress(host="address.example.com", port=6379)]
client_config = GlideClusterClientConfiguration(addresses, request_timeout=500)
client = await GlideClusterClient.create(client_config)

The connection timeout controls how long the client waits for a TCP/TLS connection to establish. This is separate from the request timeout and is configured via the advanced configuration.

from glide import (
GlideClusterClient,
GlideClusterClientConfiguration,
AdvancedGlideClusterClientConfiguration,
NodeAddress
)
addresses = [NodeAddress(host="address.example.com", port=6379)]
client_config = GlideClusterClientConfiguration(
addresses,
advanced_configuration=AdvancedGlideClusterClientConfiguration(
connection_timeout=5000
)
)
client = await GlideClusterClient.create(client_config)
from glide import (
GlideClusterClient,
GlideClusterClientConfiguration,
NodeAddress,
BackoffStrategy
)
addresses = [NodeAddress(host="address.example.com", port=6379)]
client_config = GlideClusterClientConfiguration(
addresses,
reconnect_strategy=BackoffStrategy(num_of_retries=3, factor=2, exponent_base=2)
)
client = await GlideClusterClient.create(client_config)