-
Notifications
You must be signed in to change notification settings - Fork 86
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
Browser-based WebRTC support #62
Comments
Hi @sbazerque 👋 Biggest issue is that the discovery stack is UDP based so not really any APIs for that in the browser. Having said that, I’m def to to experimenting with browser transports. How big swarms were you running over WebRTC? It used to quite resource intensive but mb that’s changed :) |
There's https://github.com/RangerMauve/hyperswarm-web which uses WebRTC for browser peers and relies on a proxy to connect to node peers which might be relevant. |
Hey @sbazerque, in discovery-swarm-webrtc we found a way to build a distributed swarm with optimal connections thanks to the @RangerMauve work on mmst |
Hi @mafintosh ! Small ad-hoc networks, got a demo chat app for 2018 dweb camp, it's still up here: https://hyperhyper.space (the UI is... terse). It worked well on Chrome & Firefox but it's very light on the network (it's just text messaging). I'm working on making that into a general p2p database library and was considering swapping my network code for hyperswarm. So from what you say it would be hard, at least, to make the web-based peers interoperate with peers on real TCP/UDP. You could branch the discovery completely for web based peers, but that seems... inelegant, right? Or have some peers operate as bridges, but I see your point. |
@sbazerque If you ask me then I think you should experiment on a) how many peers can the browser can the browser support today? If we had good answers to those it be much easier to frame this conversation. |
@mafintosh yeah! I don't have answers for those concerns, but I think the only way to move forward is by experimenting. I'll play a bit more with the implementation I have (and hopefully the ones mentioned by @RangerMauve and @tinchoz49 above) and maybe this will make more sense later on. Thanks for the quick replies! |
Sounds good. This comes up a lot so would be good to share the findings here |
I'd be really interested to see something like this as well. I've been struggling trying to find a way to do this for DHT-based Secure Scuttlebutt connections in ssb-browser-demo, since it runs in the browser. |
Hi @KyleMaas and all! I've done a bit of thinking and testing since asking this question back in May. Here are my conclusions (this is still work-in-progress):
I've implemented this from scratch in what has become the transport layer for Hyper Hyper Space's core library. It uses a very basic signalling server, it's basically a single Python function. I've only done small scale testing, but it seems to work well. |
Could a libraries like Bugout, or P2PT help with this? Both libraries operate in a similar way to each other using WebTorrent & DHT to establish a WebRTC swarm and both work in the browser, although P2PT's CDN script tag isn't working right now, so that would need to be browserified from the module. |
Bugout + P2PT still rely upon webtorrent trackers to act as signaling servers, so the robustness falls back onto relying upon the tracker network existing and being able to support the capacity of maintaining many live O(N^2) websocket connections, which is a fairly sizable requirement. One track I've been working on recently is another angle: can you get signaling working entirely within the free tier of any cloud providers without any VMs? (to reduce outage or capacity bottlenecks) The answer is: yes, you can build a HTTP polling based signaling server on Cloudflare using workers + R2 for strongly consistent storage, which has a very generous free capacity. Holding open websockets right now is prohibitively expensive. Write-wise can support 500k-ish peer joins per month. The same approach will work with eg lambda + s3 (in read-after-write regions) or any other situation where a provider offers a HTTP req/response FaaS + a strongly consistent durable KV store. If a large network of these were stood up it would basically be fairly decentralized, backstopped by multiple cloud providers and futher basically reliant on the legal entities that have the credit card holds for the accounts involved remaining in good standing. GCP, AWS, Cloudflare would all work probably several others. These obviously can also gossip among themselves for providing service discovery. (You'd need to connect to the same endpoint for a given room to signal, ofc.) The services themselves could track usage and basically start throwing 429's if they're about to tip out of the free tiers. |
webTorrent is much better alternative than webRTC. |
Webtorrent also uses WebRTC. 😅 |
@gfodor Just saw this: https://github.com/gfodor/p2pcf. Nice work! |
@draeder thank you, that is what I was looking for. |
Hello! Any chances of supporting WebRTC in the browser?
Hyperswarm seems great, and supporting in-browser WebRTC swarming would add a lot of interesting use cases.
I have some experience doing swarm networking in the browser and could volunteer programming a transport implementation if there's interest.
The text was updated successfully, but these errors were encountered: