Skip to content

no peer:connect event with autoDial #664

@olivier-nerot

Description

@olivier-nerot

With libp2p V0.28, peer:connect events seems not to be fired

const peerid = ...;
const libp2p = await Libp2p.create({
        peerId: peerid,
        addresses: {
          listen: ['/ip4/0.0.0.0/tcp/0'],
        },
        modules: {
          transport: [TCP],
          streamMuxer: [Mplex],
          peerDiscovery: [MulticastDNS],
        },
        config: {
          peerDiscovery: {
            autoDial: true,
            [MulticastDNS.tag]: { // or mdns: ?
              interval: 1000,
              enabled: true,
            },
          },
        },
      });

      libp2p.on('peer:discovery', (peerId) => {
        debug('Discovered: %O', peerId);
        // libp2p.dial(peerId);
      });

      libp2p.connectionManager.on('peer:connect', (connection) => { 
        debug('peer connected %O',connection);
      });

      libp2p.start();

With the same setup, if I launch libp2p.start() from another node, the peer:discovery is well logged, but not peer:connect. I thought the autoDial:true should make a peer dials other discovered peers automatically.
I've tried also to call libp2p.dial(peerId) into the peer:discovery event, but peerId has no multiaddrs value, and have not found how to dial a discovered peer.

The documentation is sometimes confusing with this discovery process (for example, some explains to use mdns, other tells to use [MulticastDNS.tag]in config)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps updxDeveloper Experienceexp/noviceSomeone with a little familiarity can pick uphelp wantedSeeking public contribution on this issuekind/bugA bug in existing code (including security flaws)status/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions