WebTorrent is the first torrent client that works in the browser. YEP, THAT'S RIGHT. THE BROWSER.
It's written completely in JavaScript – the language of the web – and uses WebRTC for true peer-to-peer transport. No browser plugin, extension, or installation is required.
Using open web standards, WebTorrent connects website users together to form a distributed, decentralized browser-to-browser network for efficient file transfer.
Imagine a video site like YouTube, where visitors help to host the site's content. The more people that use a WebTorrent-powered website, the faster and more resilient it becomes.
Browser-to-browser communication cuts out the middle-man and lets people communicate on their own terms. No more client/server – just a network of peers, all equal. WebTorrent is the first step in the journey to redecentralize the Web.
The way we code the Web will determine the way we live online. So we need to bake our values into our code. Freedom of expression needs to be baked into our code. Privacy should be baked into our code. Universal access to all knowledge. But right now, those values are not embedded in the Web.
— Brewster Kahle, Founder of the Internet Archive (from Locking the Web Open)
One of the most exciting uses for WebTorrent is peer-assisted delivery. Non-profit projects like Wikipedia and the Internet Archive could reduce bandwidth and hosting costs by letting visitors chip in. Popular content is served browser-to-browser, quickly and cheaply. Rarely-accessed content is served reliably over HTTP from the origin server.
There are also exciting business use cases, from CDNs to app delivery.
WebTorrent has significant business potential to radically change the traditional notion of client-server, with applications for internal infrastructure and external closed user communications. WebTorrent has moved from an “idea” to a science experiment to now on the edge of being viable. This is like really, seriously cool.
— Chris Kranky (from "WebTorrent: Rethinking Delivery")
WebTorrent is still pretty new, but it's already being used in cool ways:
- WebTorrent Desktop - Streaming torrent app. For Mac, Windows, and Linux. (source code)
- Instant.io – Streaming file transfer over WebTorrent (source code)
- GitTorrent - Decentralized GitHub using BitTorrent and Bitcoin (source code)
- PeerCloud - Serverless websites via WebTorrent (source code)
- File.pizza - Free peer-to-peer file transfers in your browser (source code)
- Webtorrentapp – Platform for launching web apps from torrents
- Fastcast – Gallery site with some videos (source code)
- Colored Coins - Open protocol for creating digital assets on the Blockchain (source code)
- Tokenly Pockets - Digital token issuance with WebTorrent-based metadata (source code)
- βTorrent - Fully-featured browser WebTorrent client (source code)
- Zapsnap - Temporary peer to peer screenshot sharing from your browser (source code)
- PeerWeb - Fetch and render a static website from a torrent
- Niagara - Video player webtorrent with subtitles (zipped .srt(s))
- Vique - Video player queue to share videos
- YouShark - Web music player for WebTorrent (source code)
- Peerify - Instant Web-seeded torrents for your files
- Instant-Share - File sharing over WebTorrent
- P2PDrop - Securely share files between peers (source code)
- Twister - Decentralized microblogging service, using WebTorrent for media attachments (source code)
- PeerTube - Prototype of a decentralized video streaming platform in the web browser (source code)
- Cinematrix - Stream your favorite free content
- webtorrent-cljs - Clojurescript wrapper for WebTorrent
- Squidlink - Transfer files from A to B without the Cloud (source code)
- Web2web - Server-less & domain-less websites updatable via torrents and bitcoin blockchain (source code)
- Magnet Player - Stream video torrents directly from your browser (source code)
- PeerFast - First P2P Internet Speed Test (source code)
- TorrentMedia - Fully-featured desktop WebTorrent client
- Gaia 3D Star Map - 2 million stars, rendered in 3D with WebGL, WebVR, and WebTorrent
- Watchtor - A minimalistic approach for online torrent watching (source code)
- CacheP2P - Highly distributed cache platform (source code)
- DropClickPaste - Drop Dead Simple Content Sharing
- LocalFiles - Share files by pinning them to geographic locations
- WebTorrent Google Cast (WTGC) - Play WebTorrent media on Google Cast devices (source code)
- WebTorrent Player - A WebTorrent player built by Angular 2 and ngrx (source code)
- CodeDump - A WebTorrent based code pastebin (source code)
- Lunik-Torrent - WebTorrent downloader and file manager. (source code)
- BitChute - A decentralized video streaming social network
- Planktos - Enables websites to serve their static content over BitTorrent (source code)
- SuperQuickShare - Quickly share files between devices using webtorrent and qrcodes (source code)
- P2P-CDN - WebTorrent CDN with graceful degradation
- PearPlayer - A WebTorrent based multi-source and multi-protocol P2P streaming media player
- Tcloud - File sharing and torrent downloading
- Webtorrent-webui - A WebTorrent client with a simple web interface for easy remote usage
- CineTimes - A streaming website of public domain movies
- Bitlove.org - Your favorite podcasts via BitTorrent
- lofiTorrent - Online and offline browser torrent client
- Live-torrent - Simple implementation of a webtorrent powered live streaming solution (source code)
- CDNBye - CDNBye implements WebRTC datachannel to scale live/vod video streaming by peer-to-peer network using bittorrent-like protocol.
- Files.fm - a fast file sharing and freemium cloud storage service that uses P2P technology to accelerate unlimited downloads and file distribution.
- imgest - Serverless shareable image gallery built with JavaScript and WebTorrent.
- Bugout - build and run back-end web services in a browser tab.
- P2P Media Loader - engine for Hls.js and Shaka Player that enables P2P sharing of live and VOD streams over HLS or DASH protocols.
- Cheff - Share food recipes between your devices. source code
- Hubzilla - WebTorrent player integration into posts (source code)
- Your app here – Send a pull request with your URL!
There's also a list of WebTorrent-powered alternatives to centralized services here: WebTorrent Product Clones
The WebTorrent protocol works just like BitTorrent protocol, except it uses WebRTC instead of TCP/uTP as the transport protocol.
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.
The protocol changes we made will be published as a
BEP. Until a spec is written, you
can view the source code of the bittorrent-tracker
package.
Once peers are connected, the wire protocol used to communicate is exactly the same as in normal BitTorrent. This should make it easy for existing popular torrent clients like Transmission, and uTorrent to add support for WebTorrent. Vuze already has support for WebTorrent!
To start using WebTorrent, simply include the
webtorrent.min.js
script on your page. If you use browserify, you can
npm install webtorrent
and require('webtorrent')
.
It's easy to download a torrent and add it to the page.
var client = new WebTorrent()
var torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'
client.add(torrentId, function (torrent) {
// Torrents can contain many files. Let's use the .mp4 file
var file = torrent.files.find(function (file) {
return file.name.endsWith('.mp4')
})
file.appendTo('body') // append the file to the DOM
})
This supports video, audio, images, PDFs, Markdown, and more, right out of the box. There are additional ways to access file content directly, including as a node-style stream, Buffer, or Blob URL.
Video and audio content can be streamed, i.e. playback will start before the full file is downloaded. Seeking works too – WebTorrent dynamically fetches the needed torrent pieces from the network on-demand.
WebRTC (Web Real-Time Communication) is an API defined by the World Wide Web Consortium (W3C) to support browser-to-browser applications like voice calling, video chat, and P2P file sharing without the need for browser plugins.
WebRTC's RTCDataChannel
API allows the transfer of data directly from one browser
to another. This is distinct from WebSocket
and XMLHttpRequest
because these are
designed for communication to/from a server, i.e. a client-server model. Data
Channels allow for direct browser-to-browser connections.
This is revolutionary. Never before could websites connect their users directly to each other with super low-latency, encrypted, peer-to-peer connections. This will enable next-generation applications in healthcare, education, science, and more. WebTorrent is just one example.
WebRTC works everywhere, and browser support is excellent. Chrome, Firefox, and Opera for Desktop and Android, as well as Microsoft Edge and Safari have support.
You can learn more about WebRTC data channels at HTML5Rocks.
In the browser, WebTorrent can only download torrents that are seeded by a WebRTC-capable torrent client.
Right now, we know of these WebRTC-capable torrent clients:
- WebTorrent Desktop - Open source streaming torrent client. For Mac, Windows, and Linux.
- Vuze - Powerful, full-featured torrent client
- Playback - Open source JavaScript video player (super cool!)
webtorrent-hybrid
- Node.js package (command line and API)- Instant.io - Simple WebTorrent client in a website
- βTorrent - Fully-featured browser WebTorrent client (source code)
- TorrentMedia - Desktop WebTorrent client
- More coming soon – Send a PR to add your client to the list!
In node.js, webtorrent-hybrid
can download torrents from WebRTC peers or TCP peers
(i.e. normal peers). You can use WebTorrent as a command line program, or
programmatically as a node.js package.
To install webtorrent-hybrid
run the following command in your terminal (add the
-g
flag to install the command line program, omit it to install locally):
npm install webtorrent-hybrid -g
Note: If you just need to use WebTorrent in the browser (where WebRTC is available
natively) then use webtorrent
instead, which is faster to install
because it won't need to install a WebRTC implementation.
Yes! WebTorrent works across the entire web. WebTorrent clients running on one domain can connect to clients on any other domain. No silos!
The same-origin policy does not apply to WebRTC connections since they are not client-to-server. Browser-to-browser connections require the cooperation of both websites (i.e. the WebTorrent script must be present on both sites).
WebTorrent is built by Feross Aboukhadijeh and hundreds of open source contributors. The WebTorrent project is managed by WebTorrent, LLC, as a non-profit project.
Feross's other projects include JavaScript Standard Style, PeerCDN (sold to Yahoo), Study Notes, and YouTube Instant.
In the past, Feross attended Stanford University, did research in the Stanford Human-Computer Interaction and Computer Security labs, and worked at Quora, Facebook, and Intel.
"WebTorrent, LLC" is the legal entity that owns WebTorrent. WebTorrent is, and always will be, non-profit, open source, and free software.
There are no plans to make a profit from WebTorrent.
PeerCDN was a next-generation CDN powered by WebRTC for efficient peer-to-peer delivery of website content. PeerCDN was founded by Feross Aboukhadijeh, Abi Raja, and John Hiesey in March 2013 and was sold to Yahoo in December 2013.
WebTorrent is an independent project started by Feross Aboukhadijeh in October 2013. Unlike PeerCDN, WebTorrent is free software, licensed under the MIT License. You're free to use it however you like!
"Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
— Richard Stallman, software freedom activist
On a technical level, PeerCDN and WebTorrent were built with different goals in mind. PeerCDN was optimized for low-latency downloads and fast peer discovery. This meant the client and site owner trusted centralized servers to map file URLs to content hashes.
WebTorrent, on the other hand, doesn't require clients to trust a centralized
server. Given a .torrent
file or magnet link, the WebTorrent client downloads the
file without trusting servers or peers at any point.
WebTorrent is an OPEN Open Source Project. Individuals who make significant and valuable contributions are given commit access to the project to contribute as they see fit. (See the full contributor guidelines.)
There are many ways to help out!
- Report bugs by creating a GitHub issue.
- Write code to fix an open issue.
If you're looking for help getting started, come join us in Gitter or on
IRC at #webtorrent
(freenode) and how you can get started.
There are many talks online about WebTorrent. Here are a few:
<iframe width="853" height="480" src="https://www.youtube.com/embed/kxHRATfvnlw?rel=0" frameborder="0" allowfullscreen></iframe> <script async class="speakerdeck-embed" data-id="cb08869f2ac2445c99e8b73a4ac65d2b" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>BitTorrent clients select which file pieces to download using an algorithm called "rarest-first". With every peer in the system trying to download the rarest pieces first, on average most pieces will have approximately the same availability in the network.
In practice, the rarest-first algorithm is most important on poorly-seeded torrents, or in the first few hours of a torrent being published (when the ratio of seeders to leechers is bad).
Most torrent clients support features that cause it to deviate from a pure rarest- first selection algorithm. For example, the ability to select/deselect or prioritize/deprioritize certain files in the torrent.
WebTorrent supports streaming a torrent file "in order", which is useful for playing back media files. We’re working on improving the algorithm to switch back to a rarest-first strategy when there is not a high-priority need for specific pieces. In other words, when sufficient media is buffered, we can use the normal "rarest-first" piece selection algorithm.
But the fact is that with the speed of today’s internet connections, the user is going to finish fully downloading the torrent in a fraction of the time it takes to consume it, so they will still spend more time seeding than downloading.
Also note: BitTorrent Inc.'s official torrent client, uTorrent, offers sequential downloading, as well as selective file downloading, and the BitTorrent network remains very healthy.
BitTorrent is the most successful, most widely-deployed P2P protocol in existence. It works really well. Our goal with WebTorrent was to bring BitTorrent to the web in a way that interoperates with the existing torrent network.
Re-inventing the protocol would have made WebTorrent fundamentally incompatible with existing clients and prevented adoption. The way we've done it is better. The wire protocol is exactly the same, but there's now a new way to connect to peers: WebRTC, in addition to the existing TCP and uTP.
Also, re-inventing the protocol is a huge rabbit hole. There was already a lot of risk when we started the project -- will WebRTC get adopted by all the browser vendors? Will the Data Channel implementation stabilize and be performant? Is JavaScript fast enough to re-package MP4 videos on-the-fly for streaming playback with the MediaSource API? Our thinking was: Why add inventing a new wire protocol and several algorithms to the table?
It's true that the BitTorrent protocol is dated in some ways. For example, it uses it's own strange data encoding called "bencoding". If it were invented today, it would probably just use JSON or MessagePack. But, this doesn't matter -- BitTorrent works really well, and we care more about building robust and useful software than conceptual purity or the latest software fashions.
WebTorrent cannot do live streaming out-of-the-box, however you can build a live streaming solution on top of WebTorrent.
Torrents are immutable. That means that once a torrent file is created, it cannot be changed without changing the info hash. So, how could one get around this limitation?
A naive approach would be this: The content producer could take every 10 seconds of live content and create a torrent for it. Viewers would follow this "feed" of torrent files (or info hashes) and download the content sequentially. Streamers would be around 10-20 seconds behind the live stream.
This approach can definitely be improved, though! Why not give that a shot yourself and share the code?
No.
WebRTC data channels do not allow a website to discover your public IP address when there is a VPN in use. The WebRTC discovery process will just find your VPN's IP address and the local network IP address.
Local IP addresses (e.g. 10.x.x.x or 192.168.x.x) can potentially be used to "fingerprint" your browser and identify across different sites that you visit, like a third-party tracking cookie. However, this is a separate issue than exposing your real public IP address, and it's worth noting that the browser already provides hundreds of vectors for fingerprinting you (e.g. your installed fonts, screen resolution, browser window size, OS version, language, etc.).
If you have a VPN enabled, then WebRTC data channels will not connect to peers using your true public IP address, nor will it be revealed to the JavaScript running on the webpage.
At one point in time, WebRTC did have an issue where it would allow a website to discover your true public IP address, but this was fixed a long time ago. This unfortunate misinformation keeps bouncing around the internet.
There's now a spec that defines exactly which IP addresses are exposed with WebRTC. If you're interested in further reading, you can read the IP handling spec for yourself.
It does work! But you can't just use any random magnet uri or .torrent
file. The
torrent must be seeded by a WebRTC-capable client, i.e.
WebTorrent Desktop, Vuze,
webtorrent-hybrid, Playback,
instant.io, or βTorrent.
In the browser, WebTorrent can only download torrents that are explicitly seeded to web peers via a WebRTC-capable client. Desktop torrent clients need to support WebRTC to connect to web browsers.
Streaming support depends on support for MediaSource
API in the browser. All
modern browsers have MediaSource
support. In Firefox, support was added in
Firefox 42 (i.e. Firefox Nightly).
Many file types are supported (again, depending on browser support),
but only .mp4
, .m4v
, and .m4a
have full support, including seeking.
To support video/audio streaming of arbitrary files, WebTorrent uses the
videostream
package, which in turn uses mp4box.js
.
If you think there may be a bug in one of these packages, please file an issue on
the respective repository.
Open an issue on the WebTorrent issue tracker, or join us in
Gitter or on IRC at #webtorrent
(freenode).