WebTorrent
WebTorrent is a streaming torrent client for node.js and the browser. YEP, THAT'S RIGHT. It's written completely in JavaScript – the language of the web – so the same code works in both runtimes. 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! Getting Started. It only takes a few lines of code to download a torrent in the browser! To start using WebTorrent, simply include the webtorrent.min.js script on your page. Download WebTorrent for free. Webtorrent is a web based GUI written in Python for Bit Torrent Library. It is designed for server applications where installation of desktop bt clients are not feasible.
What is WebTorrent?
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 usesWebRTC for true peer-to-peer transport. No browser plugin, extension, orinstallation is required.
Using open web standards, WebTorrent connects website users together to form adistributed, decentralized browser-to-browser network for efficient file transfer.
Why is this cool?
Imagine a video site like YouTube, where visitors help to host the site'scontent. The more people that use a WebTorrent-powered website, the faster andmore resilient it becomes.
Browser-to-browser communication cuts out the middle-man and lets peoplecommunicate on their own terms. No more client/server – just a network of peers,all equal. WebTorrent is the first step in the journey toredecentralize the Web.
The way we code the Web will determine the way we live online. So we need to bakeour 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. Butright now, those values are not embedded in the Web.
— Brewster Kahle, Founder of the Internet Archive (from Locking the Web Open)
What are some use cases for WebTorrent?
One of the most exciting uses for WebTorrent is peer-assisted delivery.Non-profit projects like Wikipedia and the InternetArchive could reduce bandwidth and hosting costs by letting visitorschip 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 traditionalnotion of client-server, with applications for internal infrastructure andexternal closed user communications. WebTorrent has moved from an “idea” to ascience experiment to now on the edge of being viable. This is like really,seriously cool.
— Chris Kranky (from 'WebTorrent: Rethinking Delivery')
Who is using WebTorrent today?
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)
- 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)
- Tokenly Pockets - Digital token issuance with WebTorrent-based metadata (source code)
- βTorrent - Fully-featured browser WebTorrent client (source code)
- PeerWeb - Fetch and render a static website from a torrent
- YouShark - Web music player for WebTorrent (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)
- DropClickPaste - Drop Dead Simple Content Sharing
- FileMap - Share files by pinning them to geographic locations
- WebTorrent Google Cast (WTGC) - Play WebTorrent media on Google Cast devices (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)
- 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
- 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.
- Hubzilla - WebTorrent player integration into posts (source code)
- Come Over - Video stream sharing to watch movies together.
- Peer Web Site - Realtime P2P Web Site using WebTorrent for files and WebRTC for text.
- CipherTorrent - Online and offline browser torrent client (source code)
- Slingcode - make, run, and share web apps P2P in the browser.
- Your app here – Send a pull request with your URL!
WebTorrent Product Alternatives
There's also a list of WebTorrent-powered alternatives to centralized services here: WebTorrent Product Clones
How does WebTorrent work?
The WebTorrent protocol works just like BitTorrent protocol,except it uses WebRTC instead of TCP/uTP as the transportprotocol.
In order to support WebRTC's connection model, we made a fewchanges 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 aBEP. Until a spec is written, youcan view the source code of the bittorrent-tracker
package.
Once peers are connected, the wire protocol used to communicate is exactly the sameas in normal BitTorrent. This should make it easy for existing popular torrentclients like Transmission, and uTorrent to add support for WebTorrent. Vuzealready has support for WebTorrent!
How do I get started?
To start using WebTorrent, simply include thewebtorrent.min.js
script on your page. If you use browserify, you cannpm install webtorrent
and require('webtorrent')
.
It's easy to download a torrent and add it to the page.
This supports video, audio, images, PDFs, Markdown, and more, rightout of the box. There are additional ways to access file content directly, includingas a node-style stream, Buffer, or Blob URL.
Video and audio content can be streamed, i.e. playback will start before the fullfile is downloaded. Seeking works too – WebTorrent dynamically fetchesthe needed torrent pieces from the network on-demand.
What is WebRTC?
WebRTC (Web Real-Time Communication) is an API defined by the World Wide WebConsortium (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 browserto another. This is distinct from WebSocket
and XMLHttpRequest
because these aredesigned for communication to/from a server, i.e. a client-server model. DataChannels allow for direct browser-to-browser connections.
This is revolutionary. Never before could websites connect their users directly toeach other with super low-latency, encrypted, peer-to-peer connections. This willenable 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 asMicrosoft Edge and Safari have support.
You can learn more about WebRTC data channels at HTML5Rocks. Download microsoft 2011 office for mac.
Can WebTorrent clients connect to normal BitTorrent clients?
In the browser, WebTorrent can only download torrents that are seeded by aWebRTC-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!
A bit more about webtorrent-hybrid
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, orprogrammatically 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):
Note: If you just need to use WebTorrent in the browser (where WebRTC is availablenatively) then use webtorrent
instead, which is faster to installbecause it won't need to install a WebRTC implementation.
Can WebTorrent clients on different websites connect to each other?
Yes! WebTorrent works across the entire web. WebTorrent clients running on onedomain can connect to clients on any other domain. No silos!
The same-origin policy does not apply to WebRTC connections since they are notclient-to-server. Browser-to-browser connections require the cooperation of bothwebsites (i.e. the WebTorrent script must be present on both sites).
Who builds WebTorrent?
WebTorrent is built by Feross Aboukhadijeh and hundreds of open sourcecontributors. The WebTorrent project is managed byWebTorrent, LLC, as a non-profit project.
Feross's other projects include JavaScript Standard Style,PeerCDN (sold to Yahoo), Study Notes, andYouTube Instant.
In the past, Feross attended Stanford University, did research in theStanford Human-Computer Interaction and Computer Security labs,and worked at Quora, Facebook, and Intel.
What is WebTorrent, LLC?
'WebTorrent, LLC' is the legal entity that owns WebTorrent. WebTorrent is, andalways will be, non-profit, open source, and free software.
There are no plans to make a profit from WebTorrent.
How is WebTorrent different from PeerCDN?
PeerCDN was a next-generation CDN powered by WebRTC for efficientpeer-to-peer delivery of website content. PeerCDN was founded byFeross Aboukhadijeh, Abi Raja, and John Hiesey inMarch 2013 and was sold to Yahoo in December 2013.
WebTorrent is an independent project started by Feross Aboukhadijeh inOctober 2013. Unlike PeerCDN, WebTorrent is free software, licensed under theMIT License. You're free to use it however you like!
'Free software' is a matter of liberty, not price. To understand the concept, youshould 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 inmind. PeerCDN was optimized for low-latency downloads and fast peer discovery. Thismeant the client and site owner trusted centralized servers to map file URLs tocontent hashes.
WebTorrent, on the other hand, doesn't require clients to trust a centralizedserver. Given a .torrent
file or magnet link, the WebTorrent client downloads thefile without trusting servers or peers at any point.
How can I contribute?
WebTorrent is an OPEN Open Source Project. Individuals who make significant andvaluable contributions are given commit access to the project to contribute as theysee fit. (See the full contributor guidelines.)
Online Torrent Client
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 onIRC at #webtorrent
(freenode) and how you can get started.
Where can I learn more?
There are many talks online about WebTorrent. Here are a few:
Intro to BitTorrent and WebTorrent (JSConf)
WebRTC Everywhere: Beyond the Browser (slides only)
WebTorrent supports sequential streaming. How does this affect the network?
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 piecesfirst, on average most pieces will have approximately the same availability in thenetwork.
In practice, the rarest-first algorithm is most important on poorly-seededtorrents, or in the first few hours of a torrent being published (when the ratio ofseeders 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 orprioritize/deprioritize certain files in the torrent.
WebTorrent supports streaming a torrent file 'in order', which is useful forplaying back media files. We’re working on improving the algorithm to switch backto a rarest-first strategy when there is not a high-priority need for specificpieces. 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 isgoing to finish fully downloading the torrent in a fraction of the time it takes toconsume it, so they will still spend more time seeding than downloading.
Also note: BitTorrent Inc.'s official torrent client, uTorrent, offers sequentialdownloading, as well as selective file downloading, and the BitTorrent networkremains very healthy.
Why wasn't WebTorrent designed as an entirely-new, modern protocol?
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 webin a way that interoperates with the existing torrent network.
Re-inventing the protocol would have made WebTorrent fundamentally incompatiblewith existing clients and prevented adoption. The way we've done it is better. Thewire 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 ofrisk when we started the project -- will WebRTC get adopted by all the browservendors? Will the Data Channel implementation stabilize and be performant? IsJavaScript fast enough to re-package MP4 videos on-the-fly for streaming playbackwith the MediaSource API? Our thinking was: Why add inventing a new wire protocoland several algorithms to the table?
It's true that the BitTorrent protocol is dated in some ways. For example, it usesit's own strange data encoding called 'bencoding'. If it were invented today, itwould probably just use JSON or MessagePack. But, this doesn't matter -- BitTorrentworks really well, and we care more about building robust and useful software thanconceptual purity or the latest software fashions.
Is it possible to do live streaming with WebTorrent?
WebTorrent cannot do live streaming out-of-the-box, however you can build a livestreaming solution on top of WebTorrent.
Torrents are immutable. That means that once a torrent file is created, it cannotbe changed without changing the info hash. So, how could one get around thislimitation?
A naive approach would be this: The content producer could take every 10 seconds oflive content and create a torrent for it. Viewers would follow this 'feed' oftorrent files (or info hashes) and download the content sequentially. Streamerswould be around 10-20 seconds behind the live stream.
Webtorrent App
This approach can definitely be improved, though! Why not give that a shot yourselfand share the code?
Does WebTorrent leak your IP address when using a VPN? I heard that WebRTC leaks your IP address.
No.
WebRTC data channels do not allow a website to discover your public IP address whenthere is a VPN in use. The WebRTC discovery process will just find your VPN's IPaddress 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 exposingyour real public IP address, and it's worth noting that the browser alreadyprovides 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 peersusing your true public IP address, nor will it be revealed to the JavaScript runningon the webpage.
At one point in time, WebRTC did have an issue where it would allow a websiteto discover your true public IP address, but this was fixed a long time ago. Thisunfortunate 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 theIP handling specfor yourself.
Why does browser downloading not work? I see no peers!
It does work! But you can't just use any random magnet uri or .torrent
file. Thetorrent 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 toweb peers via a WebRTC-capable client. Desktop torrent clients need to supportWebRTC to connect to web browsers.
Why does video/audio streaming not work?
Streaming support depends on support for MediaSource
API in the browser. Allmodern browsers have MediaSource
support. In Firefox, support was added inFirefox 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 thevideostream
package, which in turn uses mp4box.js
.If you think there may be a bug in one of these packages, please file an issue onthe respective repository.
Got more questions?
Open an issue on the WebTorrent issue tracker, or join us inGitter or on IRC at #webtorrent
(freenode).