Timeouts and Reconnect Strategy
Timeouts and Reconnect Strategy
Section titled “Timeouts and Reconnect Strategy”Valkey GLIDE allows you to configure timeout settings and reconnect strategies. These configurations can be applied through the ClusterClientConfiguration and ClientConfiguration 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 "github.com/valkey-io/valkey-glide/go/v2" "github.com/valkey-io/valkey-glide/go/v2/config")
func ConnectClusterWithTimeout() { myConfig := config.NewClusterClientConfiguration(). WithAddress(&config.NodeAddress{Host: "address.example.com", Port: 6379}). WithRequestTimeout(500)
client, err := glide.NewClusterClient(myConfig)}