Skip to content

Commit bfd6915

Browse files
fix: eventlistener websocket rpc version and ping
1 parent a82ddb3 commit bfd6915

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/core/src/utils/resilientEventListener.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function resilientEventListener(args: ResilientEventListenerArgs) {
5454
logCb(`[${new Date().toISOString()}] Subscribing to event listener with topic hash(es): ${topicHashes.join(', ')}`);
5555

5656
const requests = topicHashes.map((topicHash, index) => ({
57+
jsonrpc: "2.0",
5758
id: index + 1,
5859
method: "eth_subscribe",
5960
params: [
@@ -67,8 +68,9 @@ export function resilientEventListener(args: ResilientEventListenerArgs) {
6768

6869
// sending this backs should return a result of true
6970
const ping = {
71+
jsonrpc: "2.0",
7072
id: requests.length + 1,
71-
method: "net_listening",
73+
method: "net_version",
7274
params: [],
7375
};
7476

@@ -107,7 +109,7 @@ export function resilientEventListener(args: ResilientEventListenerArgs) {
107109
if (requestIndex !== -1) {
108110
subscriptionIds.push(parsedData.result);
109111
logCb(`[${new Date().toISOString()}] Subscription to event established with subscription ID '${parsedData.result}'.`);
110-
} else if (parsedData?.id === ping.id && parsedData?.result === true) {
112+
} else if (parsedData?.id === ping.id && parsedData?.result && !isNaN(Number(parsedData.result))) {
111113
logCb(`[${new Date().toISOString()}] Health check complete, subscription is still active.`)
112114
if (pingTimeout) clearTimeout(pingTimeout);
113115
} else if (parsedData?.method === 'eth_subscription' && subscriptionIds.includes(parsedData.params.subscription)) {

0 commit comments

Comments
 (0)