feat: evaluate @roamhq/wrtc as alternative to node-datachannel#3356
feat: evaluate @roamhq/wrtc as alternative to node-datachannel#3356NiKrause wants to merge 2 commits intolibp2p:mainfrom
Conversation
…p#3034) Replace node-datachannel with @roamhq/wrtc for WebRTC peer connections and stun package for STUN server functionality in WebRTC Direct. Changes: - Replace node-datachannel RTCPeerConnection with @roamhq/wrtc - Implement STUN server using stun package for WebRTC Direct - Remove DirectRTCPeerConnection wrapper class - Add extractRemoteFingerprint helper for SDP parsing - Remove node-datachannel-specific garbage collection workarounds - Add TypeScript definitions for stun package All unit tests pass (33 passing). WebRTC Direct functionality validated. Relates to libp2p#3034
- Added webrtc-roamhq-wrtc implementation variant for performance testing - Updated runner to support WebRTC Direct multiaddr handling - Added Hetzner Cloud Terraform configuration as AWS alternative - Implemented listen address capture via /tmp/webrtc-listen-addrs.txt - Fixed libp2p v2.10.0 compatibility with exact dependency versions Performance Results (Hetzner Germany, 1 iteration): - Upload: WebRTC Direct 194 Mbps vs TCP 840 Mbps - Download: WebRTC Direct 186 Mbps vs TCP 1,236 Mbps - Latency: WebRTC Direct 323ms vs TCP 124ms WebRTC Direct achieves ~186-194 Mbps throughput with @roamhq/wrtc, demonstrating functional parity with expected WebRTC overhead (~4-6x slower than TCP). Related: libp2p/js-libp2p#3356, libp2p/js-libp2p#3034, libp2p/js-libp2p#3033
|
This is looking very interesting. Any plans on releasing it (maybe as a beta if it is not ready)? I would love to give it a try. |
|
This is great. One red flag though is that the Prior to support for multiple STUN listeners per process being added to libjuice it was used here, but it was ultimately removed largely due to these critical vulnerabilities but also because the functionality was available via node-datachannel. From what I remember support for UDP multiplexing was also missing so each connection ended up using a different local port in it's ICE candidates during SDP negotiation meaning that hole punching (or UPnP port opening) was required for every inbound/outbound connection rather than everything going via a single port. I haven't looked in detail to see if that is addressed here but if not it needs to be. |
This PR evaluates @roamhq/wrtc as a replacement for node-datachannel as requested in #3034.
Implementation
Replaced node-datachannel with two libraries:
Changes
Test Results
Known Issue
Segmentation fault during test cleanup - Native module crash in @roamhq/wrtc destructor. All tests pass before crash occurs. Does not affect functionality, only test harness cleanup.
Stack trace shows crash in
RTCDataChannel::~RefPtr()andRTCPeerConnection::~RTCPeerConnection().