(评论)
(comments)

原始链接: https://news.ycombinator.com/item?id=43654813

一篇Hacker News帖子讨论了WebRTC,起因是资源“WebRTC for the Curious”。评论者们强调了WebRTC的潜力,特别是数据通道可以实现具有可靠性控制的“网络上的UDP”。用户valorzard惋惜其生态系统不如QUIC发达,尽管它对基于网页的多人游戏非常有用。 资源作者Sean-Der强调了WebRTC的应用范围远不止网页浏览器,包括远程控制、安全和机器人技术。其他人指出WebRTC实现的复杂性和样板代码,通常需要TURN服务器进行NAT穿越,这可能会抵消P2P的优势。 SDP(会话描述协议)被认为是问题的关键来源,并提到了像Pion的SDP解释器这样的解决方案。用户讨论了各种语言(Go、Rust、TypeScript、C++等)的实现。一些人争论WebRTC是否能够通过ICE和STUN绕过公司防火墙,从而创建标准HTTP连接无法建立的NAT映射。还有一个项目使用WebRTC和WebAssembly构建了一个分布式SQLite数据库。


原文
Hacker News new | past | comments | ask | show | jobs | submit login
WebRTC for the Curious (webrtcforthecurious.com)
80 points by sebg 7 hours ago | hide | past | favorite | 22 comments










WebRTC is lowkey one of the most underrated technologies out there, ESPECIALLY WebRTC data channels.

WebRTC data channels are basically “UDP on the web” but they have lots of controls to change how reliable they are, so they can be used as TCP style connections as well.

I still don’t fully understand why more people don’t use them over something like QUIC. (I think I’ve asked this question before here, but I wasn’t really satisfied with the answers)

I sadly switched off of using them, but mostly because the ecosystem around there is super underdeveloped compared to the ecosystem around QUIC/quinn. There is a LOT of boilerplate involved that feels unnecessary.

But, if you’re making a multiplayer game in the web, it’s basically the best technology to use cuz it already works. And if you use a library like libdatachannel or pion, you could make the game in Go or C++ and compile it for both Steam and the web!

Here’s a project I did with them that shows off compiled for both web and desktop: https://github.com/ValorZard/gopher-combat



I am so happy that WebRTC has so many implementations. Every developer thinks differently, it's good to have a implementation that matches your mindset.

* https://github.com/shinyoshiaki/werift-webrtc (Typescript)

* https://github.com/pion/webrtc (Golang)

* https://github.com/webrtc-rs/webrtc (Rust)

* https://github.com/algesten/str0m (Rust)

* hhttps://github.com/sepfy/libpeer (C/Embedded)

* https://webrtc.googlesource.com/src/ (C++)

* https://github.com/sipsorcery-org/sipsorcery (C#)

* https://github.com/paullouisageneau/libdatachannel (C++)

* https://github.com/elixir-webrtc (Elixir)

* https://github.com/aiortc/aiortc (Python)

* GStreamer’s webrtcbin (C)

See https://github.com/sipsorcery/webrtc-echoes for examples of some running against each other.



Anyone used a JVM implementation?


Sadly, SipSorcery is lagging behind as of now. We only have H.264 and VP8 support for video, data channels only have partial implementation (only reliable ordered), and the performance of data channels is far from what it could be.

But it is a great starting point for anyone working in C#.



> I still don’t fully understand why more people don’t use them over something like QUIC

Dealing with NAT traversal especially with full-cone NATs is difficult and expensive - you have to maintain dedicated infrastructure of TURN servers for NAT and you have to proxy all your traffic through that, it's quite the overhead, especially since IPv4 addresses and bandwidth on AWS don't come cheap.



> I still don’t fully understand why more people don’t use them over something like QUIC.

> the ecosystem around there is super underdeveloped compared to the ecosystem around QUIC/quinn

> There is a LOT of boilerplate involved that feels unnecessary

I think you just answered your own question and even gave the answers I would've given.



Well it’s a bit of a chicken or the egg situation right? None of those issues will get better if no one uses it.


The horrible boilerplate and complexity is why people don't use it. Getting even simple usage examples seems to be a tall order for some use cases and LLMs are hopeless in trying to help with it.

P2P connections are also often blocked by ISPs for whatever reason, making it impossible to use without a fallback TURN server which defeats the entire purpose of the thing if you wanted to do scalable multiplayer without the server infrastructure. You're left sending over the whole stream with double the latency and have to eat all the bandwidth.



I hope everyone enjoys WebRTC for the Curious (I am one of the authors). If you have any ideas on how to make it better I would love to hear :)

WebRTC is absolutely magical. Having 'Web' in the name does it a disservice. I see it used to.

* Remotely control excavators

* Security Cameras

* Connect autonomous robots in factories

* Low latency streaming from sail boats and rocket ships

* And all the use cases you expect (Conferencing, Telehealth etc..)



My experience is WebRTC has an on-ramp problem, which this is partly to address, but it is significantly helped if you are thrown in the deep end to work on it with someone that knows the quirks already. The big thing I got from that process was to stop being afraid of reading the SDP, because a huge amount of the problems you will run into are really the result of SDP oddities. It is credit to people like the libwebrtc maintainers that the complex morass of MediaStreamTrack processing is as solid and performant as it is these days. (And extendable).

I share the view that it should form the basis of real time communication, humans involved or not, and a/v media involved or not. There seems to be some progress on applying absolute timestamps to frames, for example, however, at some point if we want to have rocket ships using it (and I do too) we will eventually need to have some way to reconcile divergent clocks used at different sources!

Sean is modestly not mentioning Pion here, which is the lower level library many golang people reach to for webrtc components, and deservedly so.



For JavaScript developers "simple-peer" npm package is very popular and makes WebRTC very simple. I don't think its' an on-ramp problem, holding it back, it's just that most apps don't necessarily benefit from P2P coms, and also I'd hazard a guess not many people know about WebRTC, yet. Just guessing.


I need to finish it but 'Reading the SDP' I hope to solve with https://pe.pion.ly/ (https://github.com/pion/explainer). You can just your Offer/Answer in and interactively explore what has been configured.

WebRTC's complexity can be frustrating. I believe it is inherent to how many things it is trying to solve. If an alternative arrives that solves everything WebRTC does, it will end up being just as complex.

Or maybe not! Time will tell.



For all those into WebRTC, I just ran across this Reddit topic (link below), and the very latest post is one about a Chat App that was apparently just completed last week:

https://www.reddit.com/r/WebRTC/comments/1jwwfj5/quanta_chat...

It mentions Nostr, and makes me realize both Nostr and WebRTC can work well together. I haven't checked, but I'd guess there are Nostr apps using WebRTC to send Nostr messages around. I mean Nostr is basically just a crypto-signed JSON object.



Thank you for not calling it WebRTC for Dummies


The “for Dummies” branding is a trademark of the publishing company Wiley, so you need a contract with them to use it.


Tell me you wrote a for dummies book without telling you wrote a for dummies book


Can webrtc technology be used to pierce through corporate firewalls?


Likely yes, via TURN servers.


Yep! ICE lets you try a bunch of different ports and protocols.

So you can have a remote peer and try to contact it via UDP/TCP/TLS. You can even attempt via multiple interfaces (Wifi and 5G).

You can then measure the packet loss/latency across these different paths and figure out which one is best.



No. It doesn't allow anything that can't be done by a browser behind a firewall connecting to a regular web server outside the firewall.


WebRTC can create a NAT Mapping via STUN (UDP). https://webrtcforthecurious.com/docs/03-connecting/#nat-mapp... that is pretty powerful compared to Client/Server HTTP.

Dependent on the firewall, but most I have seen allow NAT mapping with different behaviors.



I like this book, but it doesn't contain any code examples, so it wasn't useful to me.

I ended up adopting code from the High Performance Browser Networking book and some code examples by Google that were written like 8 years ago. It was painful to replace the outdated APIs with new ones and rewrite in TypeScript, but I eventually did it.

https://github.com/adhamsalama/webrtc/

Then I used it with WebAssembly to run a distributed SQLite database in the browser for peer-to-peer collaboration.

https://github.com/adhamsalama/sqlite-wasm-webrtc

Probably the coolest projects I have ever done, and they contain almost no backend code at all (I am a backend dev).







Join us for AI Startup School this June 16-17 in San Francisco!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact



Search:
联系我们 contact @ memedata.com