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

Piece not reverting to webseed if all webrtc peers go away #1666

Open
rohitnayak opened this issue Jul 6, 2019 · 3 comments
Open

Piece not reverting to webseed if all webrtc peers go away #1666

rohitnayak opened this issue Jul 6, 2019 · 3 comments
Labels
bug

Comments

@rohitnayak
Copy link

@rohitnayak rohitnayak commented Jul 6, 2019

WebTorrent Version: 0.103.0

OS: Windows and Centos 7,
local website served using Node's "http-server"

Browser: Chrome 75 (also Firefox 67)

What was expected

I have a multi-file torrent. It has a webseed and I start with one WebRTC peer (seeded with the webseed). I then start another client which downloads some pieces from the webrtc peer and others from the webseed (as expected).

If the webrtc peer goes away I expect that eventually the pieces being sourced from the webrtc peer will get downloaded via the webseed.

What actually happened?

If I close the tab with the WebRTC peer (effectively leaving only the webseed active) then the pieces which using the webrtc seed never switch over to the webseed. So some files never get downloaded.

I see that there is different logic for webseeds and webrtc in the _request() function of torrent.js concerning how a piece is allocated. These functions are defined in torrent-piece (https://github.com/webtorrent/torrent-piece/blob/master/index.js)

If I am reading that code correctly, once chunks are allocated for webrtc these will never be served by a webseed. Even when a peer dies leaving no webrtc sources the internal fields, _reservations and _cancellations, are not reset.

What I tried

I added a hack in _request() before the call to piece.reserve()/piece.reserveRemaining(). I reset piece._reservations and piece._cancellations if piece._cancellations is populated and there are no webrtc sources.

With this change webtorrent works as expected. The download pauses briefly as expected when my webrtc peer dies, then my change resets the piece on the next _request() call and the piece downloads using the webseed.

So have I found a bug, or am I using/configuring webtorrent incorrectly?

@PaTiToMaSteR

This comment has been minimized.

Copy link

@PaTiToMaSteR PaTiToMaSteR commented Jul 6, 2019

Great! I was a week playing how to configure webseed, so I guess in the future this post will help me out. I’m curious to know how you configured the torrent and how did you measured you were webseeding.

I tried multiple combinations, all of them using magnet links, and &xs=http://IP:PORT/Folder%20Name, as my torrent is a folder with multiple files.

In other issues Feross commented you only need to webseed the .torrent, but trying different combinations I’ve seen the GET/ of files, not sure how much were downloaded as I see WebTorrent Desktop seeding in local net, and no luck using webseed out of the local net.

May I ask you how you do the torrent config and webseed? There is almost 0 official info about this topic.

@stale

This comment has been minimized.

Copy link

@stale stale bot commented Oct 4, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Oct 4, 2019
@feross feross added the bug label Oct 6, 2019
@stale stale bot removed the stale label Oct 6, 2019
@Evoks

This comment has been minimized.

Copy link

@Evoks Evoks commented Jan 6, 2020

Hi, I have also found this problem... Is there something plan to fix that issue? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

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