Timeouts and Reconnect Strategy
Valkey GLIDE allows you to configure timeout settings and reconnect strategies. These configurations can be applied through the GlideClusterClientConfiguration and GlideClientConfiguration parameters.
| Configuration setting | Description | Default value |
|---|---|---|
| requestTimeout | This specified time duration, measured in milliseconds, represents the period during which the client will await the completion of a request. This time frame 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 |
| reconnectStrategy | The reconnection strategy defines how and when reconnection attempts are made in the event of connection failures. | Exponential backoff |
Example: Setting Increased Request Timeout for Long-Running Commands
Section titled “Example: Setting Increased Request Timeout for Long-Running Commands”import glide.api.GlideClusterClient;import glide.api.models.configuration.GlideClusterClientConfiguration;import glide.api.models.configuration.NodeAddress;
GlideClusterClient config = GlideClusterClientConfiguration.builder() .address(NodeAddress.builder() .host("address.example.com") .port(6379).build()) .requestTimeout(500) .build();
GlideClusterClient client = GlideClusterClient.createClient(config).get();