You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If network issues or other problems unexpectedly close the socket, the client will reject all commands already sent, since the server might have already executed them.
45
-
The rest of the pending commands will remain queued in memory until a new socket is established.
46
-
This behaviour is controlled by the `enableOfflineQueue` option, which is enabled by default.
47
-
48
-
The client uses `reconnectStrategy` to decide when to attempt to reconnect.
49
-
The default strategy is to calculate the delay before each attempt based on the attempt number `Math.min(retries * 50, 500)`. You can customize this strategy by passing a supported value to `reconnectStrategy` option:
50
-
51
-
52
-
1. Define a callback `(retries: number, cause: Error) => false | number | Error`**(recommended)**
53
-
```typescript
54
-
const client =createClient({
55
-
socket: {
56
-
reconnectStrategy: function(retries) {
57
-
if (retries>20) {
58
-
console.log("Too many attempts to reconnect. Redis connection was terminated");
In the provided reconnection strategy callback, the client attempts to reconnect up to 20 times with a delay of `retries * 500` milliseconds between attempts.
69
-
After approximately two minutes, the client logs an error message and terminates the connection if the maximum retry limit is exceeded.
70
-
71
-
72
-
2. Use a numerical value to set a fixed delay in milliseconds.
73
-
3. Use `false` to disable reconnection attempts. This option should only be used for testing purposes.
58
+
When the socket closes unexpectedly (without calling the `quit()` or `disconnect()` methods),
59
+
the client can automatically restore the connection. A simple
0 commit comments