Skip to content

Commit dfbc991

Browse files
authored
Increase default connection attempt timeout to 2000ms (valkey-io#4060)
* Increase default connection attempt timeout to 2000ms and add timeout recommendations in client configuration examples for Java, Node, and Python. Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com> * Update default connection timeout to 2000ms and fix documentation across Go, Java, Node, and Python configurations Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com> --------- Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
1 parent 182fbc3 commit dfbc991

File tree

9 files changed

+26
-16
lines changed

9 files changed

+26
-16
lines changed

glide-core/redis-rs/redis/src/aio/multiplexed_connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::time::Duration;
3333
use tokio_util::codec::Decoder;
3434

3535
// Default connection timeout in ms
36-
const DEFAULT_CONNECTION_ATTEMPT_TIMEOUT: Duration = Duration::from_millis(250);
36+
const DEFAULT_CONNECTION_ATTEMPT_TIMEOUT: Duration = Duration::from_millis(2000);
3737

3838
// Senders which the result of a single request are sent through
3939
type PipelineOutput = oneshot::Sender<RedisResult<Value>>;

go/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ func NewAdvancedClientConfiguration() *AdvancedClientConfiguration {
498498

499499
// WithConnectionTimeout sets the duration to wait for a TCP/TLS connection to complete.
500500
// The duration in milliseconds to wait for a TCP/TLS connection to complete. This applies both
501-
// during initial client creation and any reconnections that may occur during request processing.
501+
// during initial client creation and any reconnection that may occur during request processing.
502502
// Note: A high connection timeout may lead to prolonged blocking of the entire command
503-
// pipeline. If not explicitly set, a default value of 250 milliseconds will be used.
503+
// pipeline. If not explicitly set, a default value of 2000 milliseconds will be used.
504504
//
505505
// Using a negative value or a value that exceeds the max duration of 2^32 - 1 milliseconds will lead to an invalid
506506
// configuration.

java/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ public class Main {
216216
GlideClientConfiguration.builder()
217217
.address(NodeAddress.builder().host(host).port(port).build())
218218
.useTLS(useSsl)
219+
// It is recommended to set a timeout for your specific use case
220+
.requestTimeout(500) // 500ms timeout
219221
.build();
220222

221223
try (GlideClient client = GlideClient.createClient(config).get()) {
@@ -266,6 +268,8 @@ public class Main {
266268
GlideClusterClientConfiguration.builder()
267269
.address(NodeAddress.builder().host(host).port(port1).port(port2).port(port3).port(port4).port(port5).port(port6).build())
268270
.useTLS(useSsl)
271+
// It is recommended to set a timeout for your specific use case
272+
.requestTimeout(500) // 500ms timeout
269273
.build();
270274

271275
try (GlideClusterClient client = GlideClusterClient.createClient(config).get()) {

java/client/src/main/java/glide/api/models/configuration/AdvancedBaseClientConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public abstract class AdvancedBaseClientConfiguration {
1515

1616
/**
1717
* The duration in milliseconds to wait for a TCP/TLS connection to complete. This applies both
18-
* during initial client creation and any reconnections that may occur during request processing.
18+
* during initial client creation and any reconnection that may occur during request processing.
1919
*
20-
* <p>If not explicitly set, a default value of 250 milliseconds will be used by the Rust core.
20+
* <p>If not explicitly set, a default value of 2000 milliseconds will be used by the Rust core.
2121
*
2222
* <p>**Note**: A high connection timeout may lead to prolonged blocking of the entire command
2323
* pipeline.

java/client/src/main/java/glide/api/models/configuration/BaseClientConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public abstract class BaseClientConfiguration {
4747
/**
4848
* The duration in milliseconds that the client should wait for a request to complete. This
4949
* duration encompasses sending the request, awaiting for a response from the server, and any
50-
* required reconnections or retries. If the specified timeout is exceeded for a pending request,
50+
* required reconnection or retries. If the specified timeout is exceeded for a pending request,
5151
* it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds
5252
* will be used.
5353
*/

node/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const client = await GlideClient.createClient({
8282
addresses: addresses,
8383
// if the server uses TLS, you'll need to enable it. Otherwise, the connection attempt will time out silently.
8484
// useTLS: true,
85+
// It is recommended to set a timeout for your specific use case
86+
requestTimeout: 500, // 500ms timeout
8587
clientName: "test_standalone_client",
8688
});
8789
// The empty array signifies that there are no additional arguments.
@@ -109,6 +111,8 @@ const client = await GlideClusterClient.createClient({
109111
addresses: addresses,
110112
// if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
111113
// useTLS: true,
114+
// It is recommended to set a timeout for your specific use case
115+
requestTimeout: 500, // 500ms timeout
112116
clientName: "test_cluster_client",
113117
});
114118
// The empty array signifies that there are no additional arguments.

node/src/BaseClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export interface BaseClientConfiguration {
652652
credentials?: ServerCredentials;
653653
/**
654654
* The duration in milliseconds that the client should wait for a request to complete.
655-
* This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries.
655+
* This duration encompasses sending the request, awaiting for a response from the server, and any required reconnection or retries.
656656
* If the specified timeout is exceeded for a pending request, it will result in a timeout error.
657657
* If not explicitly set, a default value of 250 milliseconds will be used.
658658
* Value must be an integer.
@@ -756,9 +756,9 @@ export interface BaseClientConfiguration {
756756
export interface AdvancedBaseClientConfiguration {
757757
/**
758758
* The duration in milliseconds to wait for a TCP/TLS connection to complete.
759-
* This applies both during initial client creation and any reconnections that may occur during request processing.
759+
* This applies both during initial client creation and any reconnection that may occur during request processing.
760760
* **Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
761-
* If not explicitly set, a default value of 250 milliseconds will be used.
761+
* If not explicitly set, a default value of 2000 milliseconds will be used.
762762
*/
763763
connectionTimeout?: number;
764764

python/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ To install Valkey GLIDE using `pip`, follow these steps:
7777
>>> from glide import GlideClusterClientConfiguration, NodeAddress, GlideClusterClient
7878
>>> async def test_cluster_client():
7979
... addresses = [NodeAddress("address.example.com", 6379)]
80-
... config = GlideClusterClientConfiguration(addresses)
80+
... # It is recommended to set a timeout for your specific use case
81+
... config = GlideClusterClientConfiguration(addresses, request_timeout=500) # 500ms timeout
8182
... client = await GlideClusterClient.create(config)
8283
... set_result = await client.set("foo", "bar")
8384
... print(f"Set response is {set_result}")
@@ -99,7 +100,8 @@ Get response is bar
99100
... NodeAddress("server_primary.example.com", 6379),
100101
... NodeAddress("server_replica.example.com", 6379)
101102
... ]
102-
... config = GlideClientConfiguration(addresses)
103+
... # It is recommended to set a timeout for your specific use case
104+
... config = GlideClientConfiguration(addresses, request_timeout=500) # 500ms timeout
103105
... client = await GlideClient.create(config)
104106
... set_result = await client.set("foo", "bar")
105107
... print(f"Set response is {set_result}")

python/python/glide/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ class AdvancedBaseClientConfiguration:
177177
178178
Attributes:
179179
connection_timeout (Optional[int]): The duration in milliseconds to wait for a TCP/TLS connection to complete.
180-
This applies both during initial client creation and any reconnections that may occur during request processing.
180+
This applies both during initial client creation and any reconnection that may occur during request processing.
181181
**Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
182-
If not explicitly set, a default value of 250 milliseconds will be used.
182+
If not explicitly set, a default value of 2000 milliseconds will be used.
183183
tls_config (Optional[TlsAdvancedConfiguration]): The advanced TLS configuration settings.
184184
This allows for more granular control of TLS behavior, such as enabling an insecure mode
185185
that bypasses certificate validation.
@@ -236,7 +236,7 @@ class BaseClientConfiguration:
236236
request_timeout (Optional[int]): The duration in milliseconds that the client should wait for a request to
237237
complete.
238238
This duration encompasses sending the request, awaiting for a response from the server, and any required
239-
reconnections or retries.
239+
reconnection or retries.
240240
If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not
241241
explicitly set, a default value of 250 milliseconds will be used.
242242
reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of
@@ -389,7 +389,7 @@ class GlideClientConfiguration(BaseClientConfiguration):
389389
read_from (ReadFrom): If not set, `PRIMARY` will be used.
390390
request_timeout (Optional[int]): The duration in milliseconds that the client should wait for a request to complete.
391391
This duration encompasses sending the request, awaiting for a response from the server, and any required
392-
reconnections or retries.
392+
reconnection or retries.
393393
If the specified timeout is exceeded for a pending request, it will result in a timeout error.
394394
If not explicitly set, a default value of 250 milliseconds will be used.
395395
reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of
@@ -554,7 +554,7 @@ class GlideClusterClientConfiguration(BaseClientConfiguration):
554554
read_from (ReadFrom): If not set, `PRIMARY` will be used.
555555
request_timeout (Optional[int]): The duration in milliseconds that the client should wait for a request to complete.
556556
This duration encompasses sending the request, awaiting for a response from the server, and any required
557-
reconnections or retries.
557+
reconnection or retries.
558558
If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly
559559
set, a default value of 250 milliseconds will be used.
560560
reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of

0 commit comments

Comments
 (0)