-
Notifications
You must be signed in to change notification settings - Fork 32
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
Help js browser peers discover each other out of the box #95
Comments
Based on https://libp2p.io/implementations/, js-libp2p doesn't support Rendezvous in the browser |
What does bootstrap refer to? And I am pretty sure Seems to be outdated! I'll put it on my list for tomorrow to update! |
Not sure what you mean with this question |
The first row in the screenshot you posted. |
I don't actually know what is referred to there. It links to the kad-DHT spec https://github.com/libp2p/specs/blob/master/kad-dht/README.md#bootstrap-process but it doesn't go into the actual details and it isn't clear what is referred to. @p-shahi Any thoughts? |
Yep, just realised that too. rust-libp2p definitely supports that so I'll update that! |
To keep the magic alive I'd be interested in trying to come up with a way to get users (who can't or won't run local server clients) to collaborate in support of browser-browser connectivity. Harken back to the old folding@home or seti@home days? I would personally donate a node with a public IP running relayV2, thus enabling users to drive-by connect using the js-peer in this demo -- but what's the fun in that and what are we showing them anyways? Given how many conferences we all go to, I think a better use case would be to demo WebRTC data channel establishment & signaling via QRcode in person. This has an interesting property as it requires you to actually talk to people, and gives you a cool reason to do so. Each time you connect you get one non-financial/non-redeemable libp2p point to be proudly showcased in your git profile, via IPLD 💚 |
Thanks for your input @maceip — I appreciate your willingness to help and donate.
That's pretty neat, but it's worth pointing out that this approach would only work on a local network due to NAT hole punching. Here's some prior work on this: |
precisely! what better way to demo the power of libp2p than at a conference hall with 10-10k people all on the same (v)LAN! If you want an online demo that shows how a users browser window can connect to a hosted relay / hosted peer, we can definitely do that but if you are going to hardcode the multiaddr -- what is the user journey here? Nevertheless, watching the the js helia / ipfs debug output (like in the repo's listed below ::hattip:: @achingbrain ) makes it worthwhile to just get something up that works: https://github.com/ipfs-shipyard/www-helia-identify/tree/main/src I'm not sure the best way to donate here -- it's likely that i'll spin up some server, give it dns, and then in ~5 years i'll be on an island and forget about it and rm -rf it :( |
If both parties have a connection to the relay, all the QR code needs to contain is the nodes peer ID and you are good to connect! |
I spun up a node on AWS in milan (closest region to istanbul), running latest helia / ubuntu / caddy. the username.rs domain was purchased by me a few days ago to try to take over the world but that never happened, so it is unused. I can donate this to y'all if needed. The AWS account has startup accelerator credits so at a minimum it will fund this relay for 12 months. at the moment it's not doing ci/cd, but can do later. -> relay info: https://relay.username.rs/info/ and the hosted js-peer, bootstrapping off the relay: and the stable multiaddr browsers can use as a bootstrap:
will upload the repo and share -- y'all can decide what you want to do with it or how to manage it. |
Thanks for opening this @2color this type of functionality was provided out of the box with js-libp2p-webrtc-star where i could simply https://github.com/libp2p/js-libp2p-webrtc-star/blob/master/packages/webrtc-star-signalling-server/DEPLOYMENT.md and have two browser windows doing pubsub and automatically discovering each other, for ui/ux that feels just like doing pubsub over a centralized server. But recreating this after the depreciation of the star protocols has proven a major challenge for me |
Wrote up a proposal for ambient peer discovery here: libp2p/specs#587 |
Thanks @maceip for your efforts. I was able to connect from the browser app to Not exactly sure why, but even once the connection between two browser nodes is established, exchanging chat messages doesn't work. Not sure exactly why.
We were thinking of prefilling the multiaddr input field with the deployed rust peer multiaddr, and allowing the user to optionally connect to it or alternatively, passing in your own relay multiaddr. At this point, messages in the chat should get relayed between browser nodes, since the rust peer is also subscribed to the pubsub topic. There may be some limits to how many concurrent browser peers can exchange messages by only being connected to the rust peer. This is where directly connecting to other browser peers may be useful and where ambient peer discovery may be useful. @thomaseizinger How does that align with your vision and understanding of the protocol constraints? |
Just tested it by: On one tab I went to /u/, it connected to bootstrap relay, then I copied it's WebRTC multiaddr:
I then opened another tab and browsed to /u/, and after it connected to the relay I pasted in the above WebRTC multiaddr and hit connect. It connected and then chat worked: |
Thanks @maceip — I tried again and it works. It didn't work the first time because I mistakenly used the Anyway, with the webrtc multiaddr, the chat works too! Now we have to figure out ambient peer discovery |
There are for sure limits! We don't have any numbers on gossipsub messages but the IPFS bootstrap nodes handled 40k connections pretty easily with ~ 300kb RAM per connection. Based on the available RAM on the smallest fly.io instance that we are running on, that is about 500 connections :) |
This made me think that we probably want to add some connection limits :) |
A couple of thoughts on how we could we could improve browser-to-browser connectivity out of the box this without necessarily introducing a new protocol:
|
Background
When I initially created this project, I aimed to have it simply work when loaded in the browser for demo purposes. I wanted to show how easy libp2p makes it for different runtimes and languages to connect to each other — even when behind NAT.
I wanted to be able to just share the URL as part of a talk/demo, and for browsers to just establish connectivity with each other.
Moreover, it expands the scope of this demo app to include a critical part of any libp2p app, namely peer discovery/routing.
Current challenges
There's no existing protocol or suggestions regarding how browsers should discover each other's webrtc multiaddrs.
The example relies on hardcoded ephemeral multiaddrs — this is actually an antipattern because the multiaddrs are invalid after a the certificates are rotated (~ 2 weeks).
Ideal case
Open questions
The text was updated successfully, but these errors were encountered: