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

Not working on node.js (what am I doing wrong?) #492

Closed
elad opened this issue Nov 24, 2015 · 1 comment
Closed

Not working on node.js (what am I doing wrong?) #492

elad opened this issue Nov 24, 2015 · 1 comment

Comments

@elad
Copy link

@elad elad commented Nov 24, 2015

Hi,

I'm trying to create a torrent in one process and download it in another.

Here's my seed.js:

var WebTorrent = require('webtorrent');

var client = new WebTorrent();

var file = process.argv[2];

client.seed(file, function (torrent) {
  console.log('seeding:', torrent.infoHash, 'magnetURI:', torrent.magnetURI);
});

Here's my download.js:

var WebTorrent = require('webtorrent');

var client = new WebTorrent();

var magnetURI = process.argv[2];

client.add(magnetURI, function (torrent) {
  console.log('downloading:', torrent.infoHash);

  torrent.files.forEach(function (file) {
    var source = file.createReadStream();
    var destination = fs.createWriteStream('downloads/' + file.name);
    source.pipe(destination);
  });
});

In the shell, I type:

echo 'hello world' > hello.txt
node seed.js hello.txt

And get this output:

seeding: 7b5e918f364908afab937ecdd84059dfb61102b7 magnetURI: magnet:?xt=urn:btih:7b5e918f364908afab937ecdd84059dfb61102b7&dn=hello.txt&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80&tr=wss%3A%2F%2Ftracker.webtorrent.io

In another terminal, I use the above magnet URI:

mkdir downloads
node download.js 'magnetURI: magnet:?xt=urn:btih:7b5e918f364908afab937ecdd84059dfb61102b7&dn=hello.txt&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80&tr=wss%3A%2F%2Ftracker.webtorrent.io'

But the transfer never happens.

What am I doing wrong?

Other info: I'm doing this test on Mac OS X, using two terminal windows. The computer is behind a NAT.

@elad

This comment has been minimized.

Copy link
Author

@elad elad commented Nov 29, 2015

I started my own tracker that didn't filter anything and things started working. My fault, sorry for the noise!

@elad elad closed this Nov 29, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 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
1 participant
You can’t perform that action at this time.