Skip to content

feat: Add WebSocket and WebRTC transports to relay server example #6030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

r-zig
Copy link
Contributor

@r-zig r-zig commented May 22, 2025

Description

This PR addresses issue #6029 by adding WebSocket and WebRTC transport support to the relay server example.
While full WebRTC interoperability is not yet supported, these changes lay the groundwork for ongoing efforts to enable and test connectivity between peers behind different private NATs and VPNs.
This work is particularly relevant for use cases involving interoperability with other libp2p implementations, such as js-libp2p-example-webrtc-private-to-private, and is a step toward seamless connectivity between browser-based JS peers, Rust processes, and both Rust and JS relays.

Related:
libp2p/js-libp2p-examples#226.
libp2p/js-libp2p-examples#227.
Draft: WebRTC Implementation for Browser to Browser #5978

Fixes: libp2p/rust-libp2p#6029.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @r-zig. Some high-level comments, but please see #6029 (comment) for the general discussion.

@@ -0,0 +1 @@
RUST_LOG=info cargo run -- --port 4884 --secret-key-seed 0 --websocket-port 8080 --webrtc-port 8081
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the effort, but I don't think we should add run scripts that hard-code the parameters. Most user want to change these parameters anyway, and having to think about them IMO also helps the general understanding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will move them to a new repo that provide examples.

Comment on lines 16 to 18
libp2p-webrtc = { workspace = true, features = ["tokio"] }
libp2p-noise = { workspace = true }
libp2p-tls = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use them through the libp2p meta crate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the tls & noise , but webrtc is not exposed via the libp2p meta crate

Copy link
Member

@dariusc93 dariusc93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but have webrtc-direct been tested while being used as a relay recently? Not sure if there have been any recent changes but during my testing, I ran into an issue. See #5453. Could you please confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relay server: support listening on both WebRTC and WebSocket
3 participants