Hi, I am investigating libp2p to implement P2P communication over the Internet with Rust. From reading the documentation, it seems that libp2p does not support NAT traversal yet.
I think the only way to do this is to use circuit relays. The documentation does not explain about the specific relay peer construction procedure. How do I build a relay peer? Can we use a ready-made known public relay peer?
Best Regards,
Kenjiro
The relay example should give you a good overview on how to run a circuit relay v1 client and server.
In case you want to help test the circuit relay v2 implementation you can find a client example here and a ready made relay server on GitHub - mxinden/rust-libp2p-server.
Let us know how it goes!
Hi mxinden,
Thank you for your help, and I am sorry for the delay in replying.
I want to connect Peer A and B via Peer R. I am using the ping sample and the ready made relay server (rust-libp2p-server). However, I cannot understand how to connect Peer A and B. I have tried the following steps.
Spte1: Start rust-libp2p-server on a server (Peer R).
$ cargo run
Local peer id: PeerId("QmR")
Listening for metric requests on 0.0.0.0:8888/metrics
Listening on "/ip4/PrivateIP of R/tcp/4001"
Step2: Run the ping sample on Peer A. Since Peer B is not running at this point, we cannot specify Peer B’s PeerId. Therefore, we are dialing Peer R. I can see the Pong from Peer R.
$ cargo run –example ping /ip4/PublicIP of R/tcp/4001
Local peer id: PeerId("QmA")
Dialed /ip4/ PublicIP of R/tcp/4001/p2p/QmR
Listening on "/ip4/PrivateIP of A/tcp/58919"
Event { peer: PeerId("QmR"), result: Ok(Pong) }
Event { peer: PeerId("QmR"), result: Ok(Ping { rtt: 87.7485ms }) }
Step3: Run the ping sample on Peer B. I am going to relay through Peer R and dial into Peer A.
Expect a pong from Peer A, but no pong is sent from either Peer A or Peer R.
$ cargo run –example ping /ip4/PublicIP of R/tcp/4001/p2p/QmR/p2p-circuit/p2p/QmA
Local peer id: PeerId("QmB")
Dialed /ip4/ PublicIP of R/tcp/4001/p2p/QmR/p2p-circuit/p2p/QmA
Listening on "/ip4/PrivateIP of B/tcp/58588"
I think I am using rust-libp2p-server incorrectly, but I could not understand how to use it from the documentation. Could you please help me?
Best Regards,
Kenjiro Yamasaki