libp2p / libp2p/rust-libp2p

webrtc: wrong peer id when connecting to peer via relay

Open
#5,453 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Summary

When attempting to connect to a peer (from the browser) through a relay with webrtc-direct transport, it gives a WrongPeerId. This seems to happen because it is reporting/expecting the relay peer id instead the actual peer id whom we are connecting to via relay, likely coming from the outbound upgrade in webrtc-websys.

Expected behavior

Connect to peer over relay

Actual behavior

Errors with wrong peer id when attempting to connect to remote peer via relay

Relevant log output
/home/darius/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libp2p-swarm-0.44.2/src/lib.rs:843 Connection attempt to peer failed with WrongPeerId { obtained: PeerId("12D3KooWSsn13GxHchpG6dtr7o6ARqSkcMtsBuojgL9XU9t1M1uE"), endpoint: Dialer { address: "/ip4/XXX.XXX.XXX.XXX/udp/XXXX/webrtc-direct/certhash/uEiAX9LacN1_nm3t-qLg7Ap7g3GMiAoJgWTPwfueva3xdlg/p2p/12D3KooWSsn13GxHchpG6dtr7o6ARqSkcMtsBuojgL9XU9t1M1uE/p2p-circuit/p2p/12D3KooWR8YyQ3TxpkdS6QYNDjC18XtyqBxwaPGVMGraDmpmchqQ", role_override: Dialer } }. peer = 12D3KooWR8YyQ3TxpkdS6QYNDjC18XtyqBxwaPGVMGraDmpmchqQ;
Possible Solution

If intended, might be worth to document this until browser-to-browser is implemented (which may be the best solution), otherwise, we might need to report the correct peer id when connecting over relay (would need to evaluate other libp2p impl in how they handle relay v2 with webrtc-direct)

Version

0.53

Would you like to work on fixing this bug ?

Maybe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the outbound upgrade in webrtc-websys and the WrongPeerId handling shown in the libp2p-swarm log, then review how relay v2 and webrtc-direct identify the target peer. Done means a browser connection through a relay reports and connects to the remote peer ID rather than the relay ID, or the intended limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
distributed-systems, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.