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

Very slow fetching of metadata #1602

Closed
lacker opened this issue Mar 26, 2019 · 3 comments
Closed

Very slow fetching of metadata #1602

lacker opened this issue Mar 26, 2019 · 3 comments

Comments

@lacker
Copy link

@lacker lacker commented Mar 26, 2019

Using:
webtorrent@0.103.0
Ubuntu 18.04.2 LTS
Node v8.10.0

I have two node.js programs. One seeds a small webtorrent and another downloads it. The confusing part is that the client.add callback takes a pretty long time, about two minutes. My understanding is that that callback happens after metadata is fetched, so it seems like it is being very slow to fetch metadata.

The seeder program:

let client = new WebTorrent();
let dir = path.resolve(__dirname, "samplesite");
client.seed(dir, torrent => {
  console.log("info hash: " + torrent.infoHash);

  torrent.on("wire", (wire, addr) => {
    console.log("connected to peer with address", addr);
  });
});

The downloader program:

// From the info hash printed by the seeder program
const SAMPLESITE = "e60f82343019bd711c5c731b46e118b0f2b2ecc6";

let client = new WebTorrent();
let info = SAMPLESITE;
console.log("adding", info);
client.add(info, torrent => {
  console.log("torrent metadata is ready");
  for (let file of torrent.files) {
    console.log("file:", file.name);
  }

  torrent.on("done", () => {
    console.log("downloaded", torrent.downloaded, "bytes");
  });
});

When I run these, about two minutes go by. Then I see the seeder log "connected to peer" and the downloader log "torrent metadata is ready", and then almost instantly the download completes (because it's pretty small, like 6kb).

What could be going wrong here, or how should I be debugging?

@Fabiencdp

This comment has been minimized.

Copy link

@Fabiencdp Fabiencdp commented Mar 28, 2019

Have you tried to use the 'metadata' event instead of logging directly in the 'add' callback ?
torrent.on('metadata', function () {})

Did you use a private tracker or the default 3 ws trackers ?
i actually receive a lot of connection error with wss://tracker.fastcast.nz, and wss://tracker.openwebtorrent.com always return a timeout error.

@lacker

This comment has been minimized.

Copy link
Author

@lacker lacker commented Mar 28, 2019

I have tried that. The slowness happens before the "metadata" event gets logged.

I've been using the default trackers. Maybe I should conclude that they are just slow at times and plan to use private trackers? I think my same code was working quickly a couple weeks ago, although I am not 100% sure that it wasn't something I changed somewhere.

@lacker

This comment has been minimized.

Copy link
Author

@lacker lacker commented Mar 28, 2019

Well, I set up my own tracker and it is just much, much faster than using the default trackers. Subsecond response vs a couple minutes. I guess they are either overloaded or deprioritizing me for some unknown reason. Thanks for the suggestions @Fabiencdp

@lacker lacker closed this Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 26, 2019
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
2 participants
You can’t perform that action at this time.