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

Hybrid streaming - http + webtorrent #1386

Closed
GooG2e opened this issue May 12, 2018 · 14 comments
Closed

Hybrid streaming - http + webtorrent #1386

GooG2e opened this issue May 12, 2018 · 14 comments
Labels

Comments

@GooG2e
Copy link

@GooG2e GooG2e commented May 12, 2018

Hello!
I have a website with some videos (a lot videos - more than 3000).
Usually I stream them via http/https but in peeks I have load more than 1Gbit/s
I want to use webtorrent for hybrid streaming .
For example: user watching video and simultaneously seed it (but receive video from http because no other ways) or user start watching from webtorrent but at some moment - no others seeds and it starts download from htttp
Is there anyway I can do such thing?

As I read I understand that I can't use any clients to simultaneously stream 3000+ videos and I can't totally disable http because webtorrent stream can be not enough

So I want to listen to some advices in this way
Thank you!

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented May 13, 2018

You would have to build a custom solution where you first scrape the trackers for a certain torrent and if there are not enough peers, add HTTP webseed.

If you have a 1gbps unlimited bw server, I'd just always include it and let it max out, while rarelimit each connection.

@calvincs

This comment has been minimized.

Copy link

@calvincs calvincs commented May 13, 2018

I have played with this quite a bit. Use webseed, and do a per connection limit at X speed to conserve bandwidth, if you must, to ensure as many people as possible can start a connection/stream if no other peers are online. You can use iptables on a per connection bases to limit speeds, and or work with a load balancer to better distribute your content. You may also want to look at web seeding your content via a CDN service as well if that's an option.

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 13, 2018

hmmm
How can I add http webseed?
Can you show me a small js example please
And can you say what do I need to register file and how to do this better?

P.S. Hmm I have found webseed аfunction
Can you give somehelp with setting tracker and generating torrent or magnet for this (better generate magnet or torrent in php)

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 13, 2018

Hmm as I seed I need example to configure nginx as webseed

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 13, 2018

And one more question
I begin download with client.add
Add webseed
Will peers interconnect before they will download everything?
Or I can seed and give parts only after finishing?

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 13, 2018

@GooG2e this issue may be of interest to you.

You would have to build a custom solution where you first scrape the trackers for a certain torrent and if there are not enough peers, add HTTP webseed.

An example of this which I quickly threw together can be found here.

How can I add http webseed?

A webseed can be added by calling torrent.addWebSeed('http://example.com/path/to/torrent') assuming you have a webserver (nginx, express) which supports range requests which has the torrents content available at some path. Using express adds the option for route based logic (such as videos only accessible to certain users) and authentication.

Can you give somehelp with setting tracker and generating torrent or magnet for this (better generate magnet or torrent in php)

This may help you regarding setting trackers, look into create-torrent for torrent generation, I don't know any solutions for php unfortunately, maybe somebody else could help on this part?

And can you say what do I need to register file and how to do this better?

What do you mean by this?

Will peers interconnect before they will download everything?

Yes, peers will start uploading the moment they get a piece allowing any other peer to request this piece even while they are still downloading the file, this is the nature of the bittorrent protocol.

Or I can seed and give parts only after finishing?

There currently isn't a way to stop seeding, torrent.pause() only prevents new peer connections, maybe you could call .pause() after adding the webseed before any other peer connections are made but I haven't tested this and it likely wouldn't be reliable.

Hope this helps and answers some of your questions!

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 13, 2018

Have webseed priority over usual peers?

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 13, 2018

@GooG2e No, I don't think so. From my testing with 2 complete peers (1 webrtc, 1 webseed) to an instant.io client, the downloads were split evenly, but this was tested on a single machine so latency could cause these rates to change.

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 13, 2018

@SilentBot1 And may be you test webtorrent with some players?
such as videojs?

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 13, 2018

@GooG2e, look at this issue for links to examples of VideoJS.

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 14, 2018

@SilentBot1 tested such example with iOS11. It's support webrtc but very slow((
I am going to disable on mobile devices...

@GooG2e

This comment has been minimized.

Copy link
Author

@GooG2e GooG2e commented May 14, 2018

How can I check that webseed have the lowest priority
For example I want to use it only as starter wehn other peers are exists or no other peers

@calvincs

This comment has been minimized.

Copy link

@calvincs calvincs commented May 14, 2018

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 15, 2018

Closing this since it's not an issue with WebTorrent, but feel free to continue the discussion.

@feross feross closed this May 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.