Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upHow does WebTorrent work? #39
Comments
This comment has been minimized.
This comment has been minimized.
|
Rock solid explanation of a rock solid plan +1 |
This comment has been minimized.
This comment has been minimized.
|
I wish I could give this explanation 100000 |
This comment has been minimized.
This comment has been minimized.
|
+1 i would really want to read something about this 2014-03-07 3:48 GMT-03:00 gauravsaini notifications@github.com:
May the source be with you. |
This comment has been minimized.
This comment has been minimized.
|
Sounds fantastic! |
This comment has been minimized.
This comment has been minimized.
|
Chrome-only is not a good starting point.. |
This comment has been minimized.
This comment has been minimized.
|
Planning to switch to node-webkit so webtorrent can be native on all Thanks for the feedback. On Thursday, March 27, 2014, Panu Horsmalahti notifications@github.com
Feross |
This comment has been minimized.
This comment has been minimized.
|
@feross is the reason you're using node-webkit because of window/mac support that's missing from node-webrtc? |
This comment has been minimized.
This comment has been minimized.
|
Hmm when you switch to node-webkit, maybe consider using Vue.js for the interface since there's no more CSP issues? ;) |
This comment has been minimized.
This comment has been minimized.
|
@modeswitch no, the reason is that I want to take webtorrent, which is a whole bunch of npm modules, wrap it in a UI, and create downloadable binaries for all the major platforms. I think I could use either the webrtc from node-webrtc or the built-in support in node-webkit and it shouldn't make a difference. |
This comment has been minimized.
This comment has been minimized.
|
@yyx990803 will seriously consider it! |
This comment has been minimized.
This comment has been minimized.
|
Is it already working for (Regular)Torrents ? I spend a lot of time refactoring (and understanding) I'm interested in a BitTorrent module, similar to |
This comment has been minimized.
This comment has been minimized.
|
In fact, after a deep look into the files I think https://github.com/feross/bittorrent-client is what I'm interest in, really. But its an empty repo. You are working solely on this repo, intending to split code later on? I want to help. I promise I'll behave and absolutely not a single semicolon. |
This comment has been minimized.
This comment has been minimized.
|
@ivantodorovich I had torrent downloading working when this was a chrome app, but I'm currently refactoring most of the logic out into bittorrent-client and adding streaming logic, ala torrent-stream. Then, this repo (webtorrent) will simply host a node module and command line app. I haven't pushed my code up to the The reason I can't just re-use But I don't plan to put any webtorrent protocol specific stuff into |
This comment has been minimized.
This comment has been minimized.
|
@ivantodorovich I just pushed some code to bittorrent-client if you want to take a look. It's incomplete and untested, but if you want to take a look it's there. I'll continue updating it until it works... |
This comment has been minimized.
This comment has been minimized.
|
Great! Im currently at work and I have a busy day ahead. I ll get into it tomorrow. Take a look at my fork https://github.com/ivantodorovich/torrent-stream/tree/refactor Its a working version of torrent-stream, with a refactored code design. Its a lot easier to read than mafintosh's. |
This comment has been minimized.
This comment has been minimized.
|
A few weeks ago, I gave a talk in Budapest where I shared the current state of WebTorrent. There's been quite a bit of progress since things got started in January. "Bringing BitTorrent to the Web" If you haven't been following too closely and you're looking for an update, then this is the talk for you. I also spent some time talking about browserify, the npm way, and WebRTC |
This comment has been minimized.
This comment has been minimized.
|
Awesome !!!! What software did you use for your presentation ? It looks gorgeous ! |
This comment has been minimized.
This comment has been minimized.
|
Thanks! I used Keynote, which has really nice built-in animations. And then I just came up with a nice color scheme to use. Glad you liked it! |
This comment has been minimized.
This comment has been minimized.
|
Hey @feross, node-webkit is nice but it won't work on chromeos, so by switching to node-webkit, you'll actually be supporting one OS less which is too bad for us chromeos users I guess. Will there be a way to still run webtorrent in a chrome app? Thanks. |
This comment has been minimized.
This comment has been minimized.
|
Yep, Chrome OS support is still planned. Check out this repo: https://github.com/feross/webtorrent-chrome which has a basic working version. Development effort is focused on the node-webkit version for now but once that's released I plan to bring the Chrome App back up-to-date with all the recent progress :) |
This comment has been minimized.
This comment has been minimized.
|
I'm not a contributor at all, just a watcher, but I added a Sulia post to Please forgive the blatant nature of the Sulia identity. It's designed as a On Sat, May 17, 2014 at 6:39 PM, Feross Aboukhadijeh <
|
This comment has been minimized.
This comment has been minimized.
|
WebTorrent is now usable as a command-line program, installable via npm. Give it a shot! $ npm install webtorrent -g
$ webtorrent --helpHere's how you download a torrent: $ webtorrent "magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36"
$ cd /tmp/webtorrent # this is where all files currently goPlease report any bugs you find! Huge shoutout to @fisch0920 who helped out a ton this past week. Remember, this is just stage 1 of the greater webtorrent project. Next up is:
Join us in IRC on freenode at #webtorrent if you want to help with development, or you just want to hang out with some cool p2p / mad science hackers :) |
This comment has been minimized.
This comment has been minimized.
|
@feross So, if I summarize: you get a chrome app client + node-webkit client (using node-webkit embedded webrtc since as far as I understand node-webrtc is somewhere far from being usable on windows/mac (@modeswitch ?) too bad because I was looking for a node-webrtc like solution), they bring the files to the webtorrent network. Then you get the webtorrent client inside browsers, this one can discuss using webrtc with the above clients and other browsers clients. Now, what's the mechanism to really bring a file inside webtorrent? ie using the client browser how can I tell a chrome/node-webkit client to bring the file? This can raise some other issues like chrome/node-webkit clients seeding some "unauthorized" files, so unloading the risks to them. That's why the concepts of Peersm clients (https://github.com/Ayms/node-Tor/tree/master/install#peersm-client-installation) which are bridging the content with bittorrent are a bit different, if something can not be found in peersm network, they are asked to find it in bittorrent, then they just relay the data, don't store anything and are as discrete as possible, webtorrent does not have the same anonymity constraints but maybe this thread where the behavior is detailed can be of some interest http://lists.zooko.com/pipermail/p2p-hackers/2014-June/003272.html |
This comment has been minimized.
This comment has been minimized.
|
Hey everyone, cool repo. A coworker, @marco-c, and I seriously discussed doing something like this for Firefox OS about a year ago. Just thought I'd share some feedback based on our discussion. I like the statement: The second issue, that was a blocker for us at the time, was interop with existing torrent trackers. The torrent trackers all seem to be using UDP, which you know is a limitation to current browsers. Firefox OS recently landed support for UDP sockets, but we just covered why that solution is less than optimal. UDP sockets are being spec'ed out as part of the Raw Sockets proposal, but are only implemented today in FxOS. And I'm wouldn't hold my breath on adoption by other browser vendors or even desktop FF, but how else could we ship an email client based solely on web tech in FxOS? The third issue: interop with existing BitTorrent clients. I think you addressed this concern accurately: The final issue: only Chrome implements the FileSystem API. This is kind of necessary to support the ability to seed files, especially when the tab is reloaded. For example, let's say I have a bunch of Now that I think about it, I would recommend writing such files to indexedDB, then in the client, have UX for allowing the ArrayBuffer/File/Blob to be read out of indexedDB and downloaded to the host's filesystem. Though indexedDB is my least favorite API, and isn't available everywhere, there's libraries that help with that. As always, don't let those who say it can't be done get in the way of those doing it. ;) Keep up the good work! Always happy to help, or host a hacking session at Mozilla in Mountain View. |
This comment has been minimized.
This comment has been minimized.
|
@Ayms node-webrtc has darwin support, but Windows is not ready yet. There's no technical reason why it can't run on Windows though, mostly lack of contributions for that platform. @nickdesaulniers I'll pipe up and point to https://github.com/js-platform/filer/ (disclaimer: my project) as a file system layer on indexeddb. It implements Node's I'm also happy to host webrtc hacking sessions at Mozilla Toronto if there's interest. |
This comment has been minimized.
This comment has been minimized.
|
@modeswitch , thanks, when it's time I will definitely look at a node based client supporting webrtc for the Peersm clients (because in Peersm context some are quite allergic to google things, I don't know if there are plans at Mozilla for something like a ff app ideally working on any platform, including ff os), node-webrtc if applicable, unfortunately for windows stuff I am afraid I am not the right person to be able to contribute. @nickdesaulniers , sharing some thoughts too since some Peersm concepts are close to Webtorrent. As far as I see it the webrtc clients (that we call Peersm clients in our case) are just helpers to bring the content and maintain it alive (ie bridging to bittorrent) if too many peers close their browsers, a bit like the solid seeders in bittorrent, indeed some need to load a binary which does not make it very different from a standard client but that's supposed to be a small part of the users. Another point is that you are offloading the risks to that clients, that's why Peersm clients are implementing https://github.com/Ayms/torrent-live, they totally freeride, hide what they are really requesting and block detected spies, again that's supposed to be marginal, if not they would screw up the bittorrent protocol and everybody would end up in the blocklist. Regarding trackers or DHT, this could become an issue the day (if it happens) bittorrent clients talk webrtc (because in the meantime you know browsers can not talk to them and then implement a separate DHT), but then the DHT will talk webrtc, probably not trackers but we don't care I think. Up to now I did not really study the need for a FileSystem API, since it's not available, or let's say the current behavior using indexedDB seems enough (and probably something like filer on top of it would make it better), despite of some problems like clearing everything in Chrome if you clear the cache and some bugs reported to FF of corrupted database, these "small" drawbacks are of course not cool at all if you had dozen of GB files stored and then you must reupload everything inside your browser, let's assume this will improve in the future I am focusing more on the issue of all W3C API not handling delta data (File, indexedDB, etc), I can provide some links if there is an interest, that's really painful and inefficient, as well as the lack of streams support, which will solve the delta data issue too, we know Streams are coming but I find the process really too long and most of concerned APIs seem not to care a lot. |
This comment has been minimized.
This comment has been minimized.
|
@nickdesaulniers Thanks for your detailed feedback and questions! I've tried my best to answer your questions inline.
This is the goal. And it's now complete! WebTorrent now works in the browser, end-to-end! I deployed an example app that uses WebTorrent here: http://instant.io The code is really simple -- check it out: https://github.com/feross/instant.io/blob/master/client/index.js We need better docs, a getting started tutorial, a pretty website (#29), and more. Once we have that, we can officially announce an alpha release!
Correct. The main reason to build a native bitorrent+webtorrent app is to prove that it's possible for "hybrid" clients to work well -- and to get some clients out in the wild. The long-term goal is to get the popular bittorrent clients on the market today (uTorrent, Transmission, Vuze, etc.) to add WebRTC support, bridging the two worlds -- web and native.
You're right. We can't use UDP because that's not allowed from sandboxed webpages. But there's another, more serious issue with this approach: the WebRTC signaling process requires an offer/answer to be sent between two peers. Thus, the server needs to ability to push data down to the offering peer once the other peer sends back an answer. To solve both problems, we've modified the tracker protocol in the smallest way possible to include websocket support. The code for that is here: https://github.com/feross/webtorrent-tracker. WebSockets won't scale as well as UDP trackers do, but this approach works today! Feedback is welcome of course -- none of this is set in stone yet. The long-term goal is to build a WebRTC DHT and be minimally reliant on trackers.
It's not a good idea to implement any sort of artificial proxy bridge between WebTorrent and BitTorrent, even as a stop-gap solution until native clients add WebRTC support. No one wants that liability (anything could be transfered) and it's expensive. Even if the two networks are not joined from day 1, WebTorrent is still quite useful on it's own. For example, file sending services can be built. See: http://instant.io (source code: https://github.com/feross/instant.io) Instant uses torrent swarming for super efficient downloads. The UX needs a bit of work, but the potential is there. And there are many use cases that we likely haven't even thought of yet! Another point is that it doesn't take many people running the hybrid client for the network to be pretty robust. There is so much excess capacity on modern torrents because of super fast internet connections these days and long-term seeders.
I think IndexedDB will work, but we should consider all possible approaches. There are many excellent modules available to make that API nicer to work with. I opened a separate issue here (#86) to solicit feedback. A WebTorrent / WebRTC / P2P hackathon at Mozilla in Mountain View sounds excellent. I can help organize if that's useful. Hit me up at feross@feross.org and let's make this happen! |
This comment has been minimized.
This comment has been minimized.
I have started to write something about the "WebRTC DHT" starting here: https://github.com/Ayms/node-Tor#dht-and-bridges , maybe it's a little bit too much summarized for now, I will expand when I have time. For WebTorrent, the "modulus" does not apply and the "bridges" are the trackers, but for Peersm the bridges are only keeping references to peers, not to the content which is only referenced in the WebRTC DHT. The goal is of course to minimize the role of the trackers/bridges (and persistent WebSockets connections to them) for peers discovery and introduction. I think both projects need the same WebRTC DHT concepts, should we open a new issue to track this (and a gist to spec this)? |
This comment has been minimized.
This comment has been minimized.
|
I think @tsujio's https://github.com/tsujio/webrtc-chord is a good implementation of a DHT (Chord) with WebRTC. It's the only working/complete implementation I found. |
This comment has been minimized.
This comment has been minimized.
|
@jure thanks, I have read tsujio/webrtc-chord#2 too. What I would like to have is a "serverless WebRTC DHT", "serverless" as far as possible, in my case the bridges (https://github.com/Ayms/node-Tor/tree/master/install#node-tor-bridge-websocket-server-installation right now they implement WebSockets and will implement WebRTC later) can relay the introduction when necessary, they are "servers" or peers backend processes, question of wording, but the DHT should favor peers introduction and I don't see it really in the webrtc-chord repo. |
This comment has been minimized.
This comment has been minimized.
|
I'm very excited about this project, what i'd love to build and i think this might make it possible, is a torrent sync version of websites, that is with 2 keys one to edit the website and when to access it. see the website did exist totally peer to peer. maybe having be editable key locked away inside itself, so that people can log in an edit it just like it CMS. |
This comment has been minimized.
This comment has been minimized.
|
@marcus7777 problem with "torrent sync" is its imposible edit a torrent because even the slightest change will change the infohash and therefore create a completely new swarm. you could get around this of course by creating a new torrent each time you change the file and telling all the peers in this swarm about this new torrent and then have them redownload the files (using the old files to speed it up) but this becomes very complecated. I think the first thing todo would be to create a twitter replacement using webtorrent similar to http://twister.net.co/ this way you could see what works and doesnt. or a simple site that allows people to have html pages eg p2ppages.com/ and once you upload a page it can not be change. but you can have say p2ppages.com/saspiron which would link to a different infohash page depending on what i set it to be sorta giving the ablity to edit a page by replacing the old one. |
This comment has been minimized.
This comment has been minimized.
|
when i get some time i might work on the p2ppages idea sounds really cool now i think about it :D |
This comment has been minimized.
This comment has been minimized.
|
here is a webpage that gets loaded from a torrent http://requirebin.com/embed?gist=00a5d23120b8bafed6b4 therefore it may not ever load i will try seed as much as possible but can garentee the site will ever load. code can be seen here https://gist.github.com/miketamis/00a5d23120b8bafed6b4 and if you want to download the html page that is loaded by this webpage you can do so using instant http://instant.io/#3a3cca2992987699def85776f58c3c510bc2b166 Please message me if you get a Hello World page :D |
This comment has been minimized.
This comment has been minimized.
|
@miketamis just loading for me no hello world |
This comment has been minimized.
This comment has been minimized.
|
This is wonderful to see thanks @miketamis what i was thinking of a
|
This comment has been minimized.
This comment has been minimized.
|
Thinking about it you dont wont something like btsync or syncthing because theres a bit of overhead what you want is to store each page in a new torrent and have a logical link (maintained by mabye a DHT or a blockchain) that link to the infohash. html files are so small we can afford to hardfork them as such and we dont need to do any sort of diff patches. each image file will be a seperate torrent. this adds the additional benifit that each site wont need there own copy of a particular image they can just share it (wow that would bring a couple new way to think of image hosting) |
This comment has been minimized.
This comment has been minimized.
|
that sounds like an awesome site. so it would be a torrent for every static file and when you make changes. Replace it. So how does the update happened? i'd love it if we could avoid any centralisation. Could the logical link be held in page itself? |
This comment has been minimized.
This comment has been minimized.
|
for each logical link you would generate public and private key. then you would have a DHT where the key for the DHT would be the hash of the public key (this hash would also be consider the logical address) then to attach a logical address (public key hash) to the physical address (infohash) you would sign the infohash and the time and push it to the DHT. the newest signature attached to DHT is the current link as such. I hope this makes sense. This is also an idea (my first one) Ill probable find out something horribley wrong with it. also futher convo about this idea should be discuss somewhere else. |
This comment has been minimized.
This comment has been minimized.
|
@miketamis neat experiment – thanks for sharing! |
This comment has been minimized.
This comment has been minimized.
|
@miketamis @marcus7777 - this topic is very interesting to build completely server-less apps. Our app today is bootstrapping assets from the server and then operates serverless on top of bitcoin's blockchain and webtorrent, thanks @feross and everyone who works on this project! But we would love to get app assets from the DHT as well. See that Ethereum's Swarm project is solving this problem as well. Would you like to discuss this offline? |
This comment has been minimized.
This comment has been minimized.
|
I would like someone to clarify. In the webtorrent runtime, when someone downloads a .torrent file or makes one for a new file they plan to seed, will the torrent be lost after the session/browser is closed? |
This comment has been minimized.
This comment has been minimized.
|
@Nashorn Yes, some peer needs to be seeding a file for any peers to be able to download it. |
Let me try to clear up a little confusion about what WebTorrent is and how it works.
The goal of the project is to build a browser BitTorrent client that requires no install (no plugin/extension/etc.) and interoperates with the regular BitTorrent network, though it uses WebRTC Data Channels for peer-to-peer transport.
To accomplish that goal, I have two objectives.
The first is to develop a working JavaScript BitTorrent client as a Chrome App. This is now finished, though we still need to add support for additional features and polish to bring it on par with other modern clients. I did this first to learn how existing clients work and because lots of this code will be reused by the WebRTC client.
The second objective is to make the BitTorrent protocol work over WebRTC. The protocol obviously needs some modifications, but all the main concepts will remain intact. This new protocol will be called "the WebTorrent protocol", or "WebTorrent extensions".
We'll use this new protocol to ship a standalone JS file that webmasters can add to their site if they want to fetch files over webtorrent. All they need to provide is the info hash (or a .torrent file) (or a magnet uri) and the WebTorrent script will do the rest. We'll have a good default "viewer" UI depending on the file type: PDF viewer, image viewer, audio/video tag (if the format allows for streaming), etc. and also allow the programmer to get the data programmatically without UI too.
This standalone JS file will eventually be the primary WebTorrent client that most users interact with. Eventually, I hope that popular tracker sites will add it to their site to make consuming torrent content easier.
So, why the Chrome App?
We'll add support for the WebTorrent protocol to the Chrome App so it will speak both protocols, meaning it can connect to both normal and web-based clients. This accomplishes two things:
Remember, until mainstream BitTorrent clients support WebTorrent, the web-based clients using the standalone JS file can only download from from other web-based clients. Browsers can't open arbitrary tcp/udp connections -- just WebRTC connections. So, essentially, we're bootstrapping the WebTorrent network by "bridging" it with the existing BitTorrent network.
Eventually, mainstream BitTorrent clients could add support for WebTorrent by using libjingle or other WebRTC bindings (see node-webrtc) so that WebTorrent clients can directly connect to them.
Questions/feedback welcome.
UPDATE: Now planning to use node-webkit to release native binaries for all major platforms instead of a chrome app, due to excessive chrome app CSP restrictions which make development not fun.