Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webtorrent support #138

Closed
faddat opened this issue Dec 11, 2016 · 59 comments
Closed

Webtorrent support #138

faddat opened this issue Dec 11, 2016 · 59 comments
Assignees
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt

Comments

@faddat
Copy link

faddat commented Dec 11, 2016

Issuehunt badges

Does this client by any chance support webtorrent?

If no, anyone know of a go torrent solution that does?

thanks!


IssueHunt Summary

anacrolix anacrolix has been rewarded.

Backers (Total: $250.00)

  • steelbrain steelbrain ($50.00)
  • $200.00 have been anonymously funded.

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

@anacrolix
Copy link
Owner

Do you refer to https://github.com/feross/webtorrent ? Can you link to a spec on bittorrent clients interacting with webrtc clients?

@faddat
Copy link
Author

faddat commented Dec 15, 2016

Not offhand, but I'm happy to google for it....

To leverage existing WebRTC implementations a dedicated instance of a Chromium browser is used. This 'bridge' mediates communication between Vuze and WebTorrent peers.
For the original implementation see https://webtorrent.io/

....ouch.

Maybe I can find better in the node.js?

@anacrolix
Copy link
Owner

That's as much as I found. If you found specifics in the node.js code, that may expedite adding support for this.

@faddat
Copy link
Author

faddat commented Jan 2, 2017

@feross

@feross
Copy link

feross commented Jan 21, 2017

Hey! We'd love to help make WebTorrent support happen here. We're working on a spec. I'll share here when it's complete. At the moment you can check out the following files, to see what's going on:

To sum up what it would take to support this:

  • webrtc library or bindings in Go
  • websocket library

When a ws:// or wss:// tracker is detected, create a websocket connection to that server. There are a few extra announce message types to facilitate establishing webrtc connections "offer" and "answer", but everything else is essentially the same.

Once connected to a peer over WebRTC, you can treat the remote peer exactly the same -- the wire protocol is exactly the same.

@mattlepacek
Copy link

Webtorrent support here would be amazing. The current node.js implementations are limited by chromes implementation of webrtc causing cpu time to multiply with each torrent being seeded. I'm interested in sponsoring Webtorrent support

@anacrolix
Copy link
Owner

I'll revisit this when there's a spec.

@KeizerDev

This comment has been minimized.

@anacrolix
Copy link
Owner

No progress. There's no spec, and WebRTC is abysmal to work with.

@Sean-Der
Copy link
Contributor

Sean-Der commented Jul 7, 2018

Hey @anacrolix !

I have been working on Go native WebRTC https://github.com/pions/webrtc and would love to get it to the point that you could use it!

It currently has full support for Audio/Video (send and recv) and I am maybe two weeks out from finishing DataChannels. We have ~5 developers involved, so things are moving pretty quick! If you are interested would love to chat/figure out what is most important to you. All the devs are on the Gophers slack in the #pion channel

@anacrolix
Copy link
Owner

That sounds great @Sean-Der . I'm guessing WebRTC is not so simple as a stream of bytes, when data-channels are ready we can look at integrating those. Specifically dial/accept interfaces are required, and a way to send/receive bytes. A spec on how the peer protocol operates over WebRTC is still required.

Unrelated, there was a comment earlier about websocket trackers, I've yet to see any in the wild. Some examples of those will be helpful. Implementing those should be very easy.

@jimmywarting

This comment has been minimized.

@anacrolix

This comment has been minimized.

@Sean-Der

This comment has been minimized.

@backkem
Copy link

backkem commented Nov 26, 2018

Quick update on pions/webrtc: we've finished implementing DTLS and plan to land it in master as soon as December 1st. This enables WebRTC in pure Go!

I reached out in chihaya/chihaya#388 for the tracker side of things.

Regarding the client side. It seems we need to:

  1. Introduce a new Webtorrent network type and revise any logic that assumes a hard coded amount of networks.
  2. Generalize the Peer struct so it can store Webtorrent peers alongside IP peers. The main difference is that they have a list of SDP offers instead of an IP+Port.
  3. Allow the Client to connect using these new type of peers. We have to choose between:
    • Passing these offers to the client as a address string like the current implementation.
    • Modifying the client to accept something more complex than just an address string. The Peer object itself for example.
  4. Create a WebRTC socket. The Listener is likely the most tricky part. It seems you have to open a bunch of PeerConnections and advertise their offer via the websocket tracker. TBD if we can use pions/dcnet to handle the connection itself.

After that we should be able to pipe the Bittorrent protocol over the WebRTC socket as usual.

@anacrolix what are your thoughts on this? Am I missing any big steps? How would you favor to handle the Webtorrent peers alongside regular IP-based peers?

@anacrolix
Copy link
Owner

@backkem It looks like you've covered all the important factors. Can you link to the WebRTC Dial/Addr/Listen equivalents so I can get a feel for how it will sit alongside the other socket types?

@Vladislavik
Copy link

Vladislavik commented Jan 26, 2019

Any news about support webrtc? It is https://github.com/gorilla/websocket
That work pretty with websockets on Go

@anacrolix
Copy link
Owner

@Vladislavik No news on WebRTC.

@jpillora
Copy link
Contributor

jpillora commented Aug 4, 2019

https://github.com/pion/webrtc

A pure Go implementation of the WebRTC API

@Sean-Der
Copy link
Contributor

Sean-Der commented Aug 5, 2019

@jpillora I would love to see that happen :)

I wish I had the bandwidth to help, but I am always behind with pion/webrtc. If you start a PR I can answer any questions/make improvements that are need to make it happen.

@jpillora

This comment has been minimized.

@Sean-Der

This comment has been minimized.

@anacrolix
Copy link
Owner

@vijayanandnandam I have Patreon, Liberapay, and GitHub Sponsors, you can view that stuff at the top of the project page when you click the Sponsor button.

@Sean-Der I've created https://issuehunt.io/r/anacrolix/torrent/issues/138, I think that should work? I'm open to suggestions.

Thanks to @backkem for his existing sponsorship.

Sorry everyone else for the noise.

@issuehunt-oss
Copy link

issuehunt-oss bot commented Jan 28, 2020

An anonymous user has funded $100.00 to this issue.


@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Jan 28, 2020
@issuehunt-oss
Copy link

issuehunt-oss bot commented Jan 28, 2020

An anonymous user has funded $100.00 to this issue.


@Sean-Der
Copy link
Contributor

@anacrolix and there it is :)

If you hit any bugs/have questions we are in Slack and would love to help. I am sure you will hit some roadblocks along the way, but will do my best to unblock you!

@anacrolix
Copy link
Owner

@Sean-Der thanks.

@issuehunt-oss
Copy link

issuehunt-oss bot commented Feb 25, 2020

@steelbrain has funded $50.00 to this issue.


@anacrolix anacrolix added this to the webtorrent-support milestone Feb 25, 2020
@anacrolix
Copy link
Owner

The Dialer and Listener interfaces have been abstracted out in #380, which is the first step toward implementing this. I've created https://github.com/anacrolix/torrent/milestone/2 to track any issues and PRs that progress this issue.

@Sean-Der
Copy link
Contributor

Anything I can do to help @anacrolix ? Happy to get involved with any of the WebRTC stuff.

@anacrolix
Copy link
Owner

anacrolix commented Mar 19, 2020

@Sean-Der I've created issues the next 2 items we need. I think it may be possible to do them concurrently, so long as the addr string is agreed upon by the tracker and Dialer implementations. See those issues for more information. I've not had time myself to progress further yet due to work and other constraints.

@anacrolix
Copy link
Owner

I did some more investigating. This looks exceptionally difficult to integrate into the existing code. The tracker and connection management are tightly coupled. It's also probably not appropriate just to maintain state at the Torrent level for trackers, it might be necessary at the Client level in order to scale to many Torrents with the same tracker URLs specified. The potential for disconnection from the trackers is a real kicker, I think there will be need to be many events flowing around the system.

@backkem
Copy link

backkem commented Apr 5, 2020

I think disconnecting form the tracker isn't the end of the world. Once established, the WebRTC connections don't need the tracker's Websocket connection to stay alive.
However, losing the connection before signaling is complete does mean you won't be able to complete the setup of a WebRTC connection.

Managing the tracker Websocket connections globally is probably a good idea since they will have more overhead than regular UDP ones.

@backkem
Copy link

backkem commented Apr 5, 2020

The WebRTC connection setup is likely even more tricky. Normally WebRTC will allocate random ports for both sides of the connection. In addition, there are two steps: signaling (tracker) and the actual connections (torrent). This would require a bunch of back-and-fort between the tracker and connection logic and it's quite inefficient for this use-case.

However, unlike in the browser we have more control over the network stack. You could potentially address these downsides as follows:

  • Create an offer with one IP and a random port (Potentially without actually allocating it but that creates a risk that it will be taken later..) and a random certificate.
  • Announce it to the tracker.
  • Create answers for incoming offers by always using one IP and the same port but different certificates.
  • Send it to the tracker.
  • Listen on that one port for incoming connections.
  • When a connection comes in, identify it by looking up the IP & certificate in the offers you received. (This may require some DTLS trickery..)
  • Establish the connection.

This would mean:

  • Decent separation between tracker & torrent connection logic.
  • Reduced need to pro-actively open a bunch of listening ports.

The pion/webrtc library should be flexible enough to make this happen.

@anacrolix
Copy link
Owner

Thanks for the assistance again @backkem. I have a in-progress branch at https://github.com/anacrolix/torrent/tree/webtorrent that's able to download. Within the torrent repo, you can test it with GOPPROF=http go run -race -v ./cmd/torrent -dht=false 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.fastcast.nz&tr=wss://tracker.openwebtorrent.com'. It's very rough for now, but I'll continue to mold it to the torrent architecture, and take suggestions and improvements from people more familiar with WebRTC and webtorrent.

@anacrolix
Copy link
Owner

That command is now $ GOPPROF=http go run -v ./cmd/torrent download -dht=false -tcpPeers=false -utpPeers=false 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.fastcast.nz&tr=wss://tracker.openwebtorrent.com'.

@anacrolix anacrolix self-assigned this Apr 13, 2020
@issuehunt-oss
Copy link

issuehunt-oss bot commented Apr 15, 2020

@anacrolix has rewarded $225.00 to @anacrolix. See it on IssueHunt

  • 💰 Total deposit: $250.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $25.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Apr 15, 2020
@anacrolix
Copy link
Owner

I'm closing this as done. There are further improvements to be made, but now that Webtorrent is supported on master, those will come over time.

@jpillora
Copy link
Contributor

jpillora commented Apr 16, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt
Projects
None yet
Development

No branches or pull requests