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

downloader fails to find seeder #194

Closed
mvayngrib opened this issue Nov 27, 2014 · 5 comments
Closed

downloader fails to find seeder #194

mvayngrib opened this issue Nov 27, 2014 · 5 comments
Labels

Comments

@mvayngrib
Copy link
Member

@mvayngrib mvayngrib commented Nov 27, 2014

Hi Feross,

I'm new at WebTorrent, so this may be a stupid question. I wrote this simple test to see if a seeder and a downloader connect. They don't, which leads me to think I'm using the library incorrectly. Can you give me a hint?

var test = require('tape');
var WebTorrent = require('webtorrent');

test('seed torrent with one client, download with another', function(t) {
  var client1 = new WebTorrent();
  var client2 = new WebTorrent();

  var buf = new Buffer('short novel about blah');

  client1.seed(buf, { name: 'blah' }, function(torrent1) {
    var timeoutId = setTimeout(function() { 
      t.fail();
      t.end(); 
    }, 30000);

    client2.download(torrent1.infoHash, function(torrent2) {
      // never gets here
      clearTimeout(timeoutId);
      t.equal(torrent1.infoHash, torrent2.infoHash);
      t.end();
    });      
  });
});
@feross feross added the question label Nov 29, 2014
@mvayngrib

This comment has been minimized.

Copy link
Member Author

@mvayngrib mvayngrib commented Nov 30, 2014

some more info, in case it helps

changed the debug line 526 in bittorrent-swarm to print the error:

debug('failed to connect %s', peer.addr, err)

seems they find each other but can't connect (see log below, that's my current public IP). I turned off my firewall, but got the same results. Will play around a bit more and report if I find the issue. Can't wait to see if it's something hilarious.

bittorrent-swarm failed to connect 71.251.213.2:58262 +2ms { [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
bittorrent-swarm failed to connect 71.251.213.2:18540 +2ms { [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
bittorrent-swarm failed to connect 71.251.213.2:18539 +0ms { [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }

@mvayngrib

This comment has been minimized.

Copy link
Member Author

@mvayngrib mvayngrib commented Dec 2, 2014

I guess it comes down to #195

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 11, 2015

Hey @mvayngrib, sorry for not replying sooner. This is a really simple issue.

This line is the culprit:

    client2.download(torrent1.infoHash, function(torrent2) {

In general, you don't want to download with just an infoHash because then you have to rely only on the DHT, which is slower than using trackers. Also, announcing to the DHT takes some time, and you're trying to search it before the message has even gotten out.

You could make your example work by switching to using torrent1.magnetURI instead of torrent1.infoHash.

Or, instead you can wait for the torrent.on('dhtAnnounce') event to know that announcing has succeeded before you start with client2.

@feross feross closed this Apr 11, 2015
@mvayngrib

This comment has been minimized.

Copy link
Member Author

@mvayngrib mvayngrib commented Apr 12, 2015

ah, i see, thanks

@cubuspl42

This comment has been minimized.

Copy link

@cubuspl42 cubuspl42 commented May 6, 2017

@feross Did you test your solution? It does not work for me.
https://gist.github.com/anonymous/3cb860cddc6a4651e59001bd6b434d59

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 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.