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

How to make downloading start faster as the demo do? #1385

Closed
hz0324 opened this issue May 12, 2018 · 7 comments
Closed

How to make downloading start faster as the demo do? #1385

hz0324 opened this issue May 12, 2018 · 7 comments
Labels

Comments

@hz0324
Copy link

@hz0324 hz0324 commented May 12, 2018

We have build a P2P share networking inside our campus based on Web Torrent.
But we found the download starts very slow. The downloader usually has to wait for 1 min.
However, If we try to download the file in the doc (https://webtorrent.io/docs), it usually starts to download at less than 10 seconds.

Please help, is there anything we can do to shorten the waiting time?
Will more seeders in different networks be helpful?
Thanks.

FYI,
1.We have set up 5 computers in different buildings around the campus, seeding the same file.
2.We have set up the rtcConfig in Twillo.
3.Our location is in Beijing, China.

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 12, 2018

Hey @hz0324,

Are you using your own tracker such as bittorrent-tracker hosted internally or are you relying on the default trackers for peer discovery? If you are using the default trackers, they are hosted in Australia (tracker.fastcast.nz), the Netherlands (tracker.openwebtorrent.com) and the United States (tracker.btorrent.xyz) so it's likely this would slow down peer discovery depending on your latency to each tracker, adding your own internal tracker could speed up peer discovery.

How are you seeding the torrent, are you using instances of instant.io open in a browser, a node applications using webtorrent-hybrid, webseeds, or your own solution?

Hopefully we can help you with this,
All the best.

@hz0324

This comment has been minimized.

Copy link
Author

@hz0324 hz0324 commented May 13, 2018

@SilentBot1

Thank you very much for the reply.

We just follow the DOC and leave everything as default when using Web Torrent in our project. I just re-read the doc and finally have idea of what the options mean. So I guess using the default tracker maybe the problem. I am gonna try to set up a special tracker server and see how it goes.

We seed files in two ways:
The first way just like the instant.io, users can seed file inside browser and download file inside browser.
The second is using webtorrent-hybrid. We write an Electron that can start to seed file according to HTTP request (an express app inside Electron app which can control the Electron app). When a user ask the server to seed certain file, it will do accordingly and the user can then download the file using browser (just like using instant.io).

BTW,
We actually know the exact public IP address of the servers that seed file. Can this information be used to speed up the peer discovery?

Thank you very much.
Have a good day.
^_^

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 13, 2018

@hz0324 It's no problem.

To pass through a custom tracker when adding a torrent, you would pass through the options object {'tracker': ['wss://tracker.example.com']} to client.add(infohash, options, ...), you can also globally set trackers when creating the client by var client = new WebTorrent(options) using the same object and these will be added to all torrents added.

With Instant.io, to add your new tracker to all added torrents you need to modify the global WEBTORRENT_ANNOUNCE calling something like WEBTORRENT_ANNOUNCE.push('wss://x.x.x.x') which will then be added to all torrents. This is the easiest, but must be done in the development console on all the initial seeding peers. On downloading peers, you could just use the magnetURI from the first seed which will contain the new tracker and not require WEBTORRENT_ANNOUNCE to be modified on every peer, only the original seeder.

Electron that can start to seed file according to HTTP request & We actually know the exact public IP address of the servers that seed file.

Because of this, you can call torrent.addWebSeed('http://10.x.x.x/path/to/torrent') and the torrent will then start to download the contents from the webseed or you could embed the webseed into the magnetURI using the &ws parameter, but this can only begin once the metadata has been retrieved, if you are using a magnetURI, peer discovery will have to occur before ut_metadata is used to transfer the metadata between peers, If you are using a .torrent file you will already have the metadata and the downloading should begin instantly from the webseed.

Hope this helps!

@hz0324

This comment has been minimized.

Copy link
Author

@hz0324 hz0324 commented May 14, 2018

@SilentBot1
Thank you very much, it is very helpful.

I am still confused about hashid and magnetURI. Right now, we are using hashid to pass torrent info, because it looks sleek and advanced. But you never mentioned it when talking about webseed. Dose it mean hashid is not supported in webseed?

BTW, torrent.addWebSeed('http://10.x.x.x/path/to/torrent')
What do you mean by "path/to/torrent"? Does it mean the http path to the exact file being seeded, something like 'path/to/school-time-table.pdf'? Or, a really torrent file?

Sorry to bother you again, I can not find clear introduction
Thanks.

@SilentBot1

This comment has been minimized.

Copy link
Member

@SilentBot1 SilentBot1 commented May 14, 2018

@hz0324

But you never mentioned it when talking about webseed. Dose it mean hashid is not supported in webseed?

Just using the infoHash of a torrent is supported, but you must add the webseed programmatically and you must first connect to a peer and download the torrents metadata using ut_metadata (which is done automatically); this will work in your situation but since peer discovery is taking a while (either because of rtcConfig as mentioned by gurupras, or through high latency to tracker) using the torrent file, or even http path to the torrent file e.g. client.add('http://10.x.x.x/path/to/torrent/example.torrent') would be more ideal until you discover what is slowing down peer discovery as it would allow the client to download from the webseed as soon as the metadata is downloaded from the example.torrent file.

What do you mean by "path/to/torrent"? Does it mean the http path to the exact file being seeded, something like 'path/to/school-time-table.pdf'? Or, a really torrent file?

For the torrent.addWebSeed function, you specify the http(s) path to the contents of the desired torrent, so in your case path/to/school-time-table.pdf or even just path/to/ for multi-file torrents and it will fill in the final part of the path name for each file.

Sorry to bother you again, I can not find clear introduction

It's no issue, happy to try and help you with the issues you're facing.

All the best.

@hz0324

This comment has been minimized.

Copy link
Author

@hz0324 hz0324 commented May 14, 2018

@SilentBot1 Thank you very much.

I have tried to set up our own tracker server according to this project bittorrent-tracker.

Although we can make server running and show the stats when visiting xx.xx.xx.xx/stats. But sadly, we cannot making the JS app using this tracker server. We tried the code you gave us and the code we found in other questions. It still connects to default tracker server, which we can saw in the developer console. And, at meantime I realized our network to these default tracker is not as slow as we thought.
We can open the website of the tracker server very quickly, such as tracker.btorrent.xyz . So I think the problem may not caused by tracker server.

Then I read this post (#1087) and realize WebSeed maybe the solution we are looking for.

So I have wrote this question : #1388

Anyway, I hope I can make it work.

This project is awesome, its doc just not as awesome as the core.
^_^

Thank you very much.
Have a good day.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 15, 2018

I'm closing this issue since there's no bug to fix here, but feel free to continue discussion!

@feross feross closed this May 15, 2018
@feross feross added the question label 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
3 participants
You can’t perform that action at this time.