diff --git a/waku/v2/node/wakunode2.go b/waku/v2/node/wakunode2.go index 70bb4813..c9105099 100644 --- a/waku/v2/node/wakunode2.go +++ b/waku/v2/node/wakunode2.go @@ -118,6 +118,7 @@ func New(ctx context.Context, opts ...WakuNodeOption) (*WakuNode, error) { w.connectionNotif = NewConnectionNotifier(ctx, host) w.host.Network().Notify(w.connectionNotif) + go w.connectednessListener() if w.opts.keepAliveInterval > time.Duration(0) { @@ -540,7 +541,13 @@ func (w *WakuNode) startKeepAlive(t time.Duration) { for { select { case <-ticker.C: - for _, p := range w.host.Network().Peers() { + // Compared to Network's peers collection, + // Peerstore contains all peers ever connected to, + // thus if a host goes down and back again, + // pinging a peer will trigger identification process, + // which is not possible when iterating + // through Network's peer collection, as it will be empty + for _, p := range w.host.Peerstore().Peers() { go pingPeer(w.ctx, w.ping, p) } case <-w.quit: