|
11 | 11 | | socket.connectTimeout | `5000` | The timeout for connecting to the Redis Server (in milliseconds) |
|
12 | 12 | | socket.noDelay | `true` | Enable/disable the use of [`Nagle's algorithm`](https://nodejs.org/api/net.html#net_socket_setnodelay_nodelay) |
|
13 | 13 | | socket.keepAlive | `5000` | Enable/disable the [`keep-alive`](https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay) functionality |
|
14 |
| -| socket.tls | | Set to `true` to enable [TLS Configuration](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback) | |
| 14 | +| socket.tls | | See explanation and examples [below](#TLS) | |
15 | 15 | | socket.reconnectStrategy | `retries => Math.min(retries * 50, 500)` | A function containing the [Reconnect Strategy](#reconnect-strategy) logic |
|
16 | 16 | | username | | ACL username ([see ACL guide](https://redis.io/topics/acl)) |
|
17 | 17 | | password | | ACL password or the old "--requirepass" password |
|
|
26 | 26 |
|
27 | 27 | ## Reconnect Strategy
|
28 | 28 |
|
29 |
| -You can implement a custom reconnect strategy as a function that should: |
| 29 | +You can implement a custom reconnect strategy as a function: |
30 | 30 |
|
31 | 31 | - Receives the number of retries attempted so far.
|
32 |
| -- Should return `number | Error`: |
33 |
| - - `number`: the time in milliseconds to wait before trying to reconnect again. |
34 |
| - - `Error`: close the client and flush the commands queue. |
| 32 | +- Returns `number | Error`: |
| 33 | + - `number`: the wait time in milliseconds prior attempting to reconnect. |
| 34 | + - `Error`: closes the client and flushes the internal command queues. |
| 35 | + |
| 36 | +## TLS |
| 37 | + |
| 38 | +When creating a client, set `socket.tls` to `true` to enable TLS. Below are some basic examples. |
| 39 | + |
| 40 | +> For configuration options see [tls.connect](https://nodejs.org/api/tls.html#tlsconnectoptions-callback) and [tls.createSecureContext](https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions), as those are the underlying functions used by this library. |
| 41 | +
|
| 42 | +### Create a SSL client |
| 43 | + |
| 44 | +```typescript |
| 45 | +createClient({ |
| 46 | + socket: { |
| 47 | + tls: true, |
| 48 | + ca: '...', |
| 49 | + cert: '...' |
| 50 | + } |
| 51 | +}); |
| 52 | +``` |
| 53 | + |
| 54 | +### Create a SSL client using a self-signed certificate |
| 55 | + |
| 56 | +```typescript |
| 57 | +createClient({ |
| 58 | + socket: { |
| 59 | + tls: true, |
| 60 | + rejectUnauthorized: true, |
| 61 | + cert: '...' |
| 62 | + } |
| 63 | +}); |
| 64 | +``` |
0 commit comments