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: lazer/sdk/js/examples/index.ts
+22-10Lines changed: 22 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,24 @@ import { PythLazerClient } from "../src/index.js";
6
6
// Ignore debug messages
7
7
console.debug=()=>{};
8
8
9
-
constclient=awaitPythLazerClient.create(
10
-
["wss://pyth-lazer.dourolabs.app/v1/stream"],
11
-
"access_token",
12
-
3,// Optionally specify number of parallel redundant connections to reduce the chance of dropped messages. The connections will round-robin across the provided URLs. Default is 3.
13
-
console,// Optionally log socket operations (to the console in this case.)
14
-
);
9
+
constclient=awaitPythLazerClient.create({
10
+
urls: [
11
+
"wss://pyth-lazer-0.dourolabs.app/v1/stream",
12
+
"wss://pyth-lazer-1.dourolabs.app/v1/stream",
13
+
],
14
+
token: "you-access-token-here",// Replace with your actual access token
15
+
numConnections: 4,// Optionally specify number of parallel redundant connections to reduce the chance of dropped messages. The connections will round-robin across the provided URLs. Default is 4.
16
+
logger: console,// Optionally log socket operations (to the console in this case.)
17
+
onError: (error)=>{
18
+
console.error("WebSocket error:",error);
19
+
},
20
+
// Optional configuration for resilient WebSocket connections
21
+
rwsConfig: {
22
+
heartbeatTimeoutDurationMs: 5000,// Optional heartbeat timeout duration in milliseconds
23
+
maxRetryDelayMs: 1000,// Optional maximum retry delay in milliseconds
24
+
logAfterRetryCount: 10,// Optional log after how many retries
25
+
},
26
+
});
15
27
16
28
// Read and process messages from the Lazer stream
* @param numConnections - The number of parallel WebSocket connections to establish (default: 3). A higher number gives a more reliable stream. The connections will round-robin across the provided URLs.
36
35
* @param logger - Optional logger to get socket level logs. Compatible with most loggers such as the built-in console and `bunyan`.
0 commit comments