WebTorrent
webtorrent.io
webtorrent.io
I hope it gets solved very soon.
I also attach my node profiling output. Looking for some advise if you have any..
[C++]:
ticks total nonlib name
5511 16.9% 43.2% epoll_pwait
692 2.1% 5.4% __pthread_cond_timedwait
682 2.1% 5.3% __lll_lock_wait
413 1.3% 3.2% __GI___pthread_mutex_lock
338 1.0% 2.6% __GI___pthread_mutex_unlock
128 0.4% 1.0% __write
84 0.3% 0.7% __pthread_cond_broadcast
83 0.3% 0.6% __lll_unlock_wake
62 0.2% 0.5% __mprotect
[Summary]: ticks total nonlib name
153 0.5% 1.2% JavaScript
8206 25.2% 64.3% C++
116 0.4% 0.9% GC
19811 60.8% Shared libraries
4411 13.5% Unaccounted
[C++ entry points]: ticks cpp total name
692 27.3% 2.1% __pthread_cond_timedwait
679 26.8% 2.1% __lll_lock_wait
413 16.3% 1.3% __GI___pthread_mutex_lock
337 13.3% 1.0% __GI___pthread_mutex_unlock
100 3.9% 0.3% __write
84 3.3% 0.3% __pthread_cond_broadcast
82 3.2% 0.3% __lll_unlock_wake
52 2.1% 0.2% __mprotectLots of other great WebRTC implementations also exist. Check out https://github.com/sipsorcery/webrtc-echoes for all the other implementations if you are open to non node.js
We got super lucky that a company heavily depended on SCTP in the early days. One of their devs (enobufs) did an amazing job with it.
Its ability to be simultaneously low-level and easy to work with is truly something else.
I don’t know of anybody who runs it in production, but its sister implementation (BitTorrent over UDP) handles 80k responses per second with lower load averages than opentorrent.
[0] https://github.com/greatest-ape/aquatic
[1]: https://github.com/snapview/tungstenite-rs
(I am the developer of aquatic)
Have there already been cases of websites making their visitors unwitting peers, similar to e.g. JavaScript cryptocurrency mining?
Of course, it is technically amazing, and pretty neat that this is possible at all, and could have some very interesting edge-use-cases.
That said, it was already highly questionable for legal application, since a torrent client can run on any machine connected to a home wifi, including guests and compromised machines. It may have been enough for a "hey, you're breaking our tos, please check your devices" from the ISP, but should never have been more than that (like threatening letters from rights-holders).
Pretty sure they can nail you even harder for piracy on this than on your own network where it might be someone else's device.
Mostly they just threaten people with lawsuits in order to get settlement money from folks who may even be fully innocent, but who cannot afford to fight against an international media empire in court. Lawsuits against random users are less common than they were, but still happen. The bigger issue is that the media industry has been pressuring ISPs to permanently disconnect users after nothing more than repeated unproven accusations of copyright infringement.
ISPs who fail to close these accounts risk being fined billions of dollars, so anyone in the US who has been getting DMCA notices from their ISP should take steps to prevent that or else they're risking getting disconnected which is a problem for those without many options for high speed internet access.
Permanently cutting people off from the internet over nothing but accusations seems very extreme, but the media industry has already taken several ISPs to court for not doing it and so far they are winning.
An explicit permission would be nicer, possibly ("this site is requesting to establish direct connections" or similar).
Controlling invasive technologies like camera use or file browsing cannot be realistically achieved by an adblocker.
Sometimes it’s just sane network management. LTE networks in particular are limited in capacity. There are a bunch of different ways to limit use with different tradeoffs, and bandwidth caps actually strike a good balance between effectiveness and predictability. I have a lot of experience thinking about and implementing bandwidth pricing models, and I don’t have time to list all the options and their tradeoffs here, but you can suggest one you think is better if you want. Bandwidth caps cause users to limit their use, while still allowing a user to use the network heavily without penalty when they need to.
The real problem here is that OP doesn’t have an intuitive UX for limiting upload bandwidth to something he is comfortable with. Webtorrent then breaks his assumption that web browsing will not incur upload bandwidth.
By "this" I mean the case in which a visitor's bandwidth is used to redistribute a file without their permission.
New tech is really nice and all, but I've never been a big fan of letting everyone and anyone run whatever code they want on my systems. If I actually need a website to do something like this I'll whitelist it or even set up a browser dedicated to that task, but at this point letting every website do whatever it wants is just dangerous.
I haven't seen it yet in websites, but I have seen video streaming apps using torrents on the backend without informing users about it. It's caused people who thought they were legally (or at least 'safely') streaming shows and movies for free using something they found in the app store to be surprised when they got hit with DMCA notices from their ISP.
Was fun until sites actually got on board with salting.
vk.com used to do that for popular videos, maybe still doing that.
The vast majority of these P2P web projects, including WebTorrent, is actually using proxy servers to fake the illusion of P2P connectivity (to be specific, they are using TURN servers to proxy traffic).
Here's a stackoverflow question I asked about this and burned a 100 bounty on it with no answers: https://stackoverflow.com/questions/70624649/webrtc-fails-to...
In 2017 appear.in published some numbers. They saw ~15% were not able to do P2P. https://medium.com/@fippo/what-kind-of-turn-server-is-being-...
Reading your stackoverflow link my guess is that you aren't using STUN. A P2P connection can't be established without a NAT hole punch.
Also if possible I would avoid the terms `Full-cone NAT` and `Symmetric NAT` they don't do a good job of describing what is actually happening. NAT Mapping/NAT Filtering is the best way to describe it. I wrote a little bit about it here [0]. To see what type of NAT you have try stun-nat-behaviour[1]
[0] https://webrtcforthecurious.com/docs/03-connecting/#nat-mapp...
[1] https://github.com/pion/stun/tree/master/cmd/stun-nat-behavi...
Thank you for this. I guess P2P connectivity is more often possible than I thought! For the record, I have tried to form P2P connections with multiple different devices and multiple different network conditions, and although I have been able to achieve connectivity with Python, I have not been able to achieve connectivity with WebRTC. So I have reason to be suspicious about claims regarding web P2P connectivity.
> Reading your stackoverflow link my guess is that you aren't using STUN. A P2P connection can't be established without a NAT hole punch.
I described NAT hole punching in my stackoverflow question, where I asked why isn't WebRTC doing this? I was using a STUN server (edit: I mixed up TURN and STUN servers and edited this post to fix that. My stackoverflow question has clear references to how I was trying to achieve connectivity - it has been a while so not everything is in clear memory for me.)
Or mobile operators being dicks because they can, that's frankly more likely.
This is not the only case where it doesn't work. One of the experiments I tried was desktop computer on fixed broadband connecting to another desktop computer on fixed broadband.
No, it's not. I've run my own webrtc signaling and STUN servers, and trying between multiple different mobile operators and devices I can establish a connection without TURN in most cases. Not 100% but in most cases.
I built a library that explores this idea: https://github.com/dmotz/trystero
And here's how it talks to WebTorrent servers to bootstrap peer connections: https://github.com/dmotz/trystero/blob/main/src/torrent.js
It also allows encrypting your peers' session descriptions to hide them from the torrent server. All of this is of course experimental and I'm very open to feedback.
I wish more people would pay attention to Trystero because it enables so many interesting use cases. It’s the foundation of https://chitchatter.im/ and I recently wrote about the potential of this library: https://dev.to/jeremyckahn/taking-the-power-back-with-web-me...
I think a better analogy is in how different countries handle national identification numbers. Some countries have a publicly accessible list encouraging people to share it when commercing, these countries usually have other means of preventing identity theft. Other countries issue identity numbers in a private manner, discouraging and prohibiting distribution. These countries use obscurity to prevent identity theft among other measure. However anecdotally it seems like identity theft is rampant in the latter countries which includes obscurity in the id-theft prevention, but not in the former.
As an alumni from a Christian school, I can confirm that this is legal. [0]
You'll get expelled if you're in a same-sex relationship, or displaying behaviors of such a relationship (e.g. holding hands). [1]
> Harding University holds to the biblical principle that God instituted marriage as a relationship between one man and one woman and that gender identity is given by God and revealed in one’s birth sex. Students are prohibited from being married to or dating a person of the same sex. Neither may students engage in behavior suggesting a romantic relationship with a person of the same sex. The University further holds to the biblical principle that sexual relationships outside the context of marriage are unacceptable to God and immoral. Sexual immorality in any form will result in suspension from the University.
[0]: https://archive.org/details/harding-title-ix-exemption/page/...
[1]: page 16: https://www.campuspride.org/wp-content/uploads/harding_stude...
In the meantime using a VPN is probably a must for the students of these schools.
PS. That is a lovely zine in the bonus citation.
If you want a real fun trip down Christian college lane you should check out PCC [0]. One of my friends went there for a semester or two and it sounded... horrible.
> PCC policies govern many aspects of the students' lives, including dress, hairstyles, cleanliness of residence hall rooms, styles of music, borrowing, off-campus employment, and Internet access.[30] For example, "All students are expected to dress modestly, in conservative fashions and . . . men are not to wear effeminate hairstyles or apparel."[31]
> PCC also prohibits physical contact and interaction between unwed members of the opposite sex. For example, a chaperone and "day-pass" is required for a "mixed group" for students under the age of 23.[32] Students over the age of 23 are not required to have a chaperone on a date, but cannot go to a beach or a park after dark and cannot "visit the home of an unmarried person of the opposite gender."[33]
> Most stairwells, elevators, and parking lots on campus are segregated by gender.
[0]: https://en.wikipedia.org/wiki/Pensacola_Christian_College
Really cool to learn that Webtorrent is a generic API that others can use. There seems to be a lot of good ways it can be used to decentralise the web again.
It's weird seeing people talk about some mythical history where the web was somehow decentralized.
The emergence of central dominant vendors for key services reduces that (AWS, MS, Google, and CloudFlare are each capable of disabling a lot of the web with a failure; and there are backbone providers that can have similar effects) somewhat, of course.
The web in real terms requires infrastructure for content to be available. Without that infrastructure you've just got dead links. But this has always been the case. There's no golden period to go back to.
The dominant players in the infrastructure business can end service for individual customers but they don't run everything. You can spin up a server and point your DNS records at it and be online if CloudFlare drops your site. They exist because it's cheaper to buy infrastructure in bulk and sublet it but that doesn't stop anyone from making their own server on their own infrastructure.
Edit: fat fingered button
This happening "for a reason" doesn't change the fact that what is now the case was once not. In 2001, if a particularly well known tech vendor screwed up their DNS, their product website would be down and everyone would shrug and go about their day. In 2022, if a particularly well known tech vendor screws up their DNS, more than 10% of the internet falls over.
The fact that I can spin up a server is true, but doesn't help me when I can't pay my bills online because a very large shopping website has gone down.
It ignores neither. The web (and the underlying internet more generally) are decentralized systems by design, but over time (because its a lot more convenient and efficient when you aren’t, say, experiencing a major widespread disaster) a lot of key functions have progressed in the direction of centralization, because unlike the prople making the original concept, most users aren’t making decisions with a nuclear exchange targeting critical communication nodes as a significant part of the threat model that their resiliency plans address.)
These aren't binary transitions (nor are they entirely monotonic), and there are very good reasons people prefer more centralization for the uses the internet has evolved to fill. But it is a real change over time.
Not only do you suffer the ads, you unwittingly contribute your resources (power and bandwidth) to propagating them
Not only does it increase accessibility of the internet for low bandwidth users (they will use more if they know they won’t blow out their budget) but it will help shame the bloated websites with more user visibility into the issue
> In order to support WebRTC's connection model, we made a few changes to the tracker protocol. Therefore, a browser-based WebTorrent client or "web peer" can only connect to other clients that support WebTorrent/WebRTC.
It's so fulfilling to see WebTorrent still popping up on Hacker News after all these years. I started the project in 2013 and devoted most of my 20s to working on it, ultimately becoming a full-time open source maintainer. I started WebTorrent with the goal of extending the BitTorrent protocol to become more web-friendly, allowing any browser to become a peer in the torrent network. Within less than a year of starting the project, I got WebTorrent fully working (see https://news.ycombinator.com/item?id=8317441). And it worked _well_, beating many native torrent apps in terms of raw download speed and the ability to stream videos within seconds of adding a torrent.
WebTorrent never got as much attention as the cryptocurrency projects selling tokens throughout the mid-2010s, even though WebTorrent _actually worked_, and it had more users than almost all of them :) I was never tempted to add a cryptotoken to WebTorrent, despite many well-meaning friends telling me to do it and cash in. Nonetheless, WebTorrent served as an accessible on-ramp to the world of decentralized tech, along with other projects like Dat (https://dat-ecosystem.org/) and Secure Scuttlebutt (https://scuttlebutt.nz/), playing a role in getting people excited about decentralization.
But WebTorrent is more than a protocol extension to BitTorrent. We also built a popular desktop torrent client, WebTorrent Desktop (https://webtorrent.io/desktop/), which supports powerful features like instant video streaming.
We also built a `webtorrent` JavaScript package (https://socket.dev/npm/package/webtorrent) which implements the full BitTorrent/WebTorrent protocol in JavaScript. This implementation uses TCP, UDP, and/or WebRTC for peer-to-peer transport in any environment – whether Node.js (TCP/UDP), Electron (TCP/UDP/WebRTC), or the web browser (WebRTC). In the browser, the `webtorrent` package uses WebRTC which doesn’t require a browser plugin, extension, or any kind of installation to work. If you’re building a website and want to fetch files from a torrent, you can use `webtorrent` to do that directly client-side, in a decentralized manner. The WebTorrent Workshop (https://webtorrent.github.io/workshop/) is helpful for getting started and teaches you how to download and stream a torrent into an HTML page in just 10 lines of code.
Now that WebTorrent is fully supported in nearly all the most popular torrent clients, including uTorrent, dare I say that we succeeded?
Not only that, but we helped the JavaScript ecosystem a ton by writing hundreds of npm packages including buffer (https://github.com/feross/buffer), simple-peer (https://github.com/feross/simple-peer), and StandardJS (https://standardjs.com/).
It's been a long and winding journey, but I'm glad to have played a role in making WebTorrent happen. Huge shoutouts to all the open source contributors to WebTorrent over the years, but especially Diego R Baquero and Alex Morais who were critical to WebTorrent's success.
If you're curious what I'm up to now... I'm building Socket (https://socket.dev) with an awesome team of open source folks. And there's actually a WebTorrent connection, too! Before Socket, we built an end-to-end encrypted file transfer app, Wormhole (https://wormhole.app), using WebTorrent under-the-hood (Show HN thread: https://news.ycombinator.com/item?id=26666142). Like Firefox Send before it, security was a primary goal of Wormhole (see security details here: https://wormhole.app/security). But one area where we felt we could improve the security of Wormhole was in how we audited our open source dependencies.
Like most teams building apps with JavaScript, we had a large `node_modules` folder filled with lots of constantly-updating third-party code. The risk of a software supply chain attack was huge, especially with 30% of Wormhole visitors coming from China. As most teams do, we enforced code review for our first-party code; but as most teams do, we pulled in third-party dependencies and dependency updates from npm without even glancing at the code. It's too much work to read every line of code of all dependencies. But the status quo would leave our users open to supply chain attack and we wanted to do better for our users. We looked around for a solution to detect signs of attack and to analyze the risk of various open source packages, but none existed.
So we built Socket to help developers ship faster and spend less time on security busywork by helping them safely find, audit, and manage OSS. By analyzing the full picture – from maintainers and how they behave, to open-source codebases and how they evolve – we help developers and security teams to identify risk from malware, hidden code, typo-squatting, misleading packages, and more.
I was looking into (ab)using webtorrent trackers as webrtc signalling servers but instead decided to write a cloudflare worker to do it [1], which is kind of a half-step towards a 'serverless' signalling layer. The next step would be to get a decentralized network that allows you to run cloudflare workers off of cloudflare. But a true DHT would be ideal.
I made a proof-of-concept of this idea during the pandemic for fun[1]. It doesn't work very well without WebRTC peers though.
Though, not that many torrent clients support WT yet, so it'll take a bit for the swarm to become multiprotocol. Same with v2 torrents really.
Just imagining someone getting their file and closing the torrent tab, I guess you could try and address this with some UI callouts, but as a frequent torrenter, since it runs on a dedicated machine/application I tend to seed heavily.
You are right, it'll be mainly used for HnRs. In some cases this is okay or even desirable.
Evil work-around: show "file-progress" as % of 2:1 seeding? File isn't 'downloaded' until you have uploaded 2x!
Never actually made it since the server that I had was actually good enough to serve people at least decently.
Not quite. Opera had built-in support for Bittorrent for quite some time: https://www.reddit.com/r/todayilearned/comments/ec79j/til_yo...
WebTorrent Desktop 0.23 - https://news.ycombinator.com/item?id=23877912 - July 2020 (36 comments)
Show HN: WebTorrent Desktop 0.22.0 - https://news.ycombinator.com/item?id=23856223 - July 2020 (2 comments)
Libtorrent adds support for the WebTorrent protocol - https://news.ycombinator.com/item?id=23818659 - July 2020 (87 comments)
Libtorrent adds support for the WebTorrent protocol - https://news.ycombinator.com/item?id=23775267 - July 2020 (1 comment)
Learn WebTorrent and WebRTC - https://news.ycombinator.com/item?id=23365708 - May 2020 (6 comments)
Dweb: Building a Resilient Web with WebTorrent - https://news.ycombinator.com/item?id=17858555 - Aug 2018 (22 comments)
Nile.js – A Peer-to-Peer Live Video Streaming Library built on WebTorrent - https://news.ycombinator.com/item?id=14443968 - May 2017 (20 comments)
Show HN: WebTorrent CDN with graceful degradation - https://news.ycombinator.com/item?id=14303618 - May 2017 (6 comments)
Instant.io – Streaming file transfer over WebTorrent - https://news.ycombinator.com/item?id=12526717 - Sept 2016 (67 comments)
Product clones using WebTorrent - https://news.ycombinator.com/item?id=12510479 - Sept 2016 (7 comments)
WebTorrent Desktop – Open source streaming torrent client - https://news.ycombinator.com/item?id=11442116 - April 2016 (80 comments)
WebTorrent – BitTorrent over WebRTC - https://news.ycombinator.com/item?id=10921773 - Jan 2016 (94 comments)
Webtorrent – BitTorrent over WebRTC - https://news.ycombinator.com/item?id=10607747 - Nov 2015 (108 comments)
Instant.io – Streaming file transfer over WebTorrent - https://news.ycombinator.com/item?id=9569315 - May 2015 (40 comments)
Node and Browser BitTorrent Client (JavaScript+WebRTC) - https://news.ycombinator.com/item?id=9336472 - April 2015 (2 comments)
Instant.io: End to end browser based web torrent - https://news.ycombinator.com/item?id=8317714 - Sept 2014 (2 comments)
WebTorrent now works in the browser, end-to-end - https://news.ycombinator.com/item?id=8317441 - Sept 2014 (83 comments)
Another nice thing about WebRTC is that it uses DTLS. You can’t block web torrents because that would also block conferencing software and corporate VPNs (Cisco)
And is ipfs better or worse?
This is kind of amusing
This is beside the point but I really, really hate when services write their home/about/faq pages in this style.