File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,24 @@ export class KeepAliveManager {
37
37
38
38
const peerIdStr = peerId . toString ( ) ;
39
39
40
+ // Ping the peer every pingPeriodSecs seconds
41
+ // if pingPeriodSecs is 0, don't ping the peer
40
42
if ( pingPeriodSecs !== 0 ) {
41
43
const interval = setInterval ( ( ) => {
42
44
void ( async ( ) => {
45
+ let ping : number ;
43
46
try {
44
47
// ping the peer for keep alive
45
48
// also update the peer store with the latency
46
- const ping = await libp2pPing . ping ( peerId ) ;
47
- log ( `Ping succeeded (${ peerIdStr } )` , ping ) ;
49
+ try {
50
+ ping = await libp2pPing . ping ( peerId ) ;
51
+ log ( `Ping succeeded (${ peerIdStr } )` , ping ) ;
52
+ } catch ( error ) {
53
+ log ( `Ping failed for peer (${ peerIdStr } ).
54
+ Next ping will be attempted in ${ pingPeriodSecs } seconds.
55
+ ` ) ;
56
+ return ;
57
+ }
48
58
49
59
try {
50
60
await peerStore . patch ( peerId , {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import debug from "debug";
15
15
16
16
import { ConnectionManager } from "./connection_manager.js" ;
17
17
18
- export const DefaultPingKeepAliveValueSecs = 0 ;
18
+ export const DefaultPingKeepAliveValueSecs = 5 * 60 ;
19
19
export const DefaultRelayKeepAliveValueSecs = 5 * 60 ;
20
20
export const DefaultUserAgent = "js-waku" ;
21
21
You can’t perform that action at this time.
0 commit comments