Skip to content

Commit 0ce9492

Browse files
authored
Merge branch 'main' into version-bump
2 parents cdc13b5 + dae947f commit 0ce9492

12 files changed

Lines changed: 644 additions & 363 deletions

File tree

docs/components/transport-types/websocket-transport.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,55 @@ In the example above, after the connection is established a custom authenticatio
109109

110110
As shown in the first example, **builders** object contains two methods, **subscribeMessage** and **unsubscribeMessage**. These methods can be provided for the WS transport to use to send subscription/unsubscription messages to Data Provider. Both accept _params_ which is the current input parameters of the request and should return object or string as payload that will be sent to Data Provider. If the payload is object it will be automatically stringified to JSON.
111111

112+
### Heartbeat messages
113+
114+
Some WebSocket providers require periodic heartbeat messages to keep the connection alive. The `WebSocketTransport` supports sending heartbeat messages automatically at a configurable interval.
115+
116+
To enable heartbeat functionality, provide a `heartbeat` handler in the `handlers` object. The heartbeat will automatically start when the connection is opened and stop when the connection is closed.
117+
118+
The `heartbeat` handler receives the WebSocket connection and adapter context, allowing you to implement any heartbeat logic you need. You can use WebSocket protocol-level ping, send custom messages, or perform any other heartbeat-related operations.
119+
120+
**Using WebSocket protocol-level ping:**
121+
122+
```typescript
123+
handlers: {
124+
heartbeat: (connection) => {
125+
connection.ping()
126+
},
127+
}
128+
```
129+
130+
**Using custom heartbeat message:**
131+
132+
```typescript
133+
handlers: {
134+
heartbeat: (connection, context) => {
135+
connection.send(JSON.stringify({
136+
type: 'ping',
137+
timestamp: Date.now(),
138+
}))
139+
},
140+
}
141+
```
142+
143+
**Using ping with optional data:**
144+
145+
```typescript
146+
handlers: {
147+
heartbeat: (connection) => {
148+
connection.ping('heartbeat-data')
149+
},
150+
}
151+
```
152+
153+
The heartbeat interval is controlled by the `WS_HEARTBEAT_INTERVAL_MS` adapter setting (default: 10000ms). The heartbeat will automatically stop if:
154+
155+
- The connection is closed
156+
- The connection state is no longer `OPEN`
157+
- A new heartbeat is started (replaces the previous one)
158+
159+
**Note:** The heartbeat only starts if the `heartbeat` handler is provided. If you don't need heartbeat functionality, simply omit the `heartbeat` handler.
160+
112161
### Retrieving and storing the response or errors
113162

114163
As shown in the first example, the **handlers** object accepts a function called **message** which will be executed when Data Provider sends a message through the WS connection. It takes this message as its first argument and the adapter context as the second, and should build and return a list of response objects (_ProviderResult_) that will be stored in the response cache for the endpoint.

docs/reference-tables/ea-settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@
6363
| TLS_PUBLIC_KEY | string | undefined | Base64 Public Key of TSL/SSL certificate | - Value must be a valid base64 string | |
6464
| WARMUP_SUBSCRIPTION_TTL | number | 300000 | TTL for batch warmer subscriptions | - Value must be an integer<br> - Value must be above the minimum<br> - Value must be below the maximum | 0 | 3600000 |
6565
| WS_CONNECTION_OPEN_TIMEOUT | number | 10000 | The maximum amount of time in milliseconds to wait for the websocket connection to open (including custom open handler) | - Value must be an integer<br> - Value must be above the minimum<br> - Value must be below the maximum | 500 | 30000 |
66+
| WS_HEARTBEAT_INTERVAL_MS | number | 10000 | The number of ms between each hearbeat message that EA sends to server, only works if heartbeat handler is provided | - Value must be an integer<br> - Value must be above the minimum<br> - Value must be below the maximum | 5000 | 300000 |
6667
| WS_SUBSCRIPTION_TTL | number | 120000 | The time in ms a request will live in the subscription set before becoming stale | - Value must be an integer<br> - Value must be above the minimum<br> - Value must be below the maximum | 0 | 3600000 |
6768
| WS_SUBSCRIPTION_UNRESPONSIVE_TTL | number | 120000 | The maximum acceptable time (in milliseconds) since the last message was received and stored in the cache on a WebSocket connection before it is considered unresponsive, causing the adapter to close and attempt to reopen it. | - Value must be an integer<br> - Value must be above the minimum<br> - Value must be below the maximum | 1000 | 180000 |

scripts/generator-adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"yeoman-generator": "7.5.1",
1515
"@yeoman/types": "1.9.1",
1616
"mem-fs": "4.1.2",
17-
"@yeoman/adapter": "3.1.1",
17+
"@yeoman/adapter": "4.0.1",
1818
"@types/node": "24.10.1"
1919
}
2020
}

scripts/generator-adapter/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"target": "es2022",
66
"downlevelIteration": true,
77
"esModuleInterop": true,
8-
"moduleResolution": "node",
9-
"module": "es2020",
8+
"moduleResolution": "nodenext",
9+
"module": "nodenext",
1010
"resolveJsonModule": true
1111
},
1212
"files": [

0 commit comments

Comments
 (0)