libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.

Home Page:https://libp2p.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rendezvous: Example "discovering with identify" doesn't work

caementarius opened this issue · comments

Summary

When launching the rendezvous example and trying to discover peers with identify, the peer abort because it can't register without knowing any external address.
Steps to reproduce

  1. Launch the server (1)
  2. Launch a peer with identify (4)

Expected behavior

As suggested in this comment, the protocol identify could allow to know and set an external address automatically and then the registration should be successfull.
Then the discovering would work as described.

Actual behavior

The peer aborts when registering because it doesn't know any external address.

Relevant log output

$ RUST_LOG=info cargo run --bin rzv-identify
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `~/rust-libp2p/target/debug/rzv-identify`
2024-05-15T06:34:58.587487Z  INFO libp2p_swarm: local_peer_id=12D3KooWNFn1BxcTXDvNY9YKY3gr4Sn3V6eTu2Pb1dPnFgtHdTHF
2024-05-15T06:34:58.587938Z  INFO rzv_identify: Listening on /ip4/127.0.0.1/tcp/37627
2024-05-15T06:34:58.587976Z  INFO rzv_identify: Listening on /ip4/192.168.1.59/tcp/37627
2024-05-15T06:34:58.675236Z ERROR rzv_identify: Failed to register: We don't know about any externally reachable addresses of ours

Possible Solution

As suggested in this post, we could use the observed address as a potential ExternalAddress.
Then we could either use it directly or use autonat to probe it and obtain a ConfirmedExternalAddress

Version

libp2p version 0.53.2

Would you like to work on fixing this bug ?

Yes

Local addresses aren't considered external addresses unless manually added, so this is kind of expected.

Local addresses aren't considered external addresses unless manually added, so this is kind of expected.

Still wouldn't it be easier to understand in the example if we explicitly register the address instead of vaguely suggest that having the protocol Identify is sufficient ?

Hi @caementarius and thanks for the interest! Want to submit a PR addressing that?

If it seems relevant enough yes why not.