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
Copy file name to clipboardExpand all lines: docs/components/transport-types/websocket-transport.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,55 @@ In the example above, after the connection is established a custom authenticatio
109
109
110
110
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.
111
111
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
+
112
161
### Retrieving and storing the response or errors
113
162
114
163
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.
Copy file name to clipboardExpand all lines: docs/reference-tables/ea-settings.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,5 +63,6 @@
63
63
| TLS_PUBLIC_KEY | string | undefined | Base64 Public Key of TSL/SSL certificate | - Value must be a valid base64 string ||
64
64
| 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 |
65
65
| 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 |
66
67
| 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 |
67
68
| 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 |
0 commit comments