From e20df9b0bb013863c3f6ca8b1d2066172df0b29b Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Sun, 27 Nov 2022 17:45:56 +0100 Subject: [PATCH] change `wakuDisconnectionTimer` to handle light protocols --- packages/status-js/src/client/client.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/status-js/src/client/client.ts b/packages/status-js/src/client/client.ts index d9cbaff5..0ec3283a 100644 --- a/packages/status-js/src/client/client.ts +++ b/packages/status-js/src/client/client.ts @@ -100,7 +100,13 @@ class Client { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore emitSelf: true, - pingKeepAlive: 15, + /** + * Note: Delegated to `wakuDisconnectionTimer`. + */ + pingKeepAlive: 0, + /** + * Note: Not supported in light mode. + */ relayKeepAlive: 0, libp2p: { peerDiscovery: [ @@ -124,7 +130,9 @@ class Client { const connectionsToClose: Promise[] = [] for (const connection of waku!.libp2p.connectionManager.getConnections()) { - if (!connection.streams.length) { + try { + await waku!.libp2p.ping(connection.remoteAddr) + } catch { connectionsToClose.push(connection.close()) } }