webtorrent / webtorrent-hybrid

WebTorrent (with WebRTC support in Node.js)
https://webtorrent.io
MIT License
519 stars 98 forks source link

Seeding via webtorrent-hybrid not working #119

Closed mayeaux closed 2 years ago

mayeaux commented 4 years ago

"webtorrent-hybrid": "^4.0.1",

OS X 10.14.4 NPM: 6.13.4 Node: v8.17.0

var WebTorrent = require('webtorrent-hybrid')

var client = new WebTorrent()

client.on('error', (err) => {
  console.error(`fatalError ${err.message || err}`);
  process.exit(1);
});

client.seed('./c5l.mp4', function (torrent) {
  torrent.on('warning', function (err) {
    console.warn(err);
  });
  torrent.on('error', function (err) {
    console.error(err);
  });

  console.log('client.seed done', {
    magnetURI: torrent.magnetURI,
    ready: torrent.ready,
    paused: torrent.paused,
    done: torrent.done,
    infohash: torrent.infoHash
  });
});

Gives me my magnet string. On the frontend I have:

script(src = 'https://cdnjs.cloudflare.com/ajax/libs/webtorrent/0.107.17/webtorrent.min.js')

script.
  var client = new WebTorrent()

// working torrentId
  var torrentId2 = 'magnet:?xt=urn:btih:c9e15763f722f23e98a29decdfae341b98d53056&dn=Cosmos+Laundromat&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fcosmos-laundromat.torrent'

// failing torrentId
  var torrentId5 = 'magnet:?xt=urn:btih:f9435fb103d53a0b3cce14afbae867cc6999d76b&dn=c5l.mp4&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.openwebtorrent.com'

  client.add(torrentId5, function (torrent) {
    // Torrents can contain many files. Let's use the .mp4 file
    var file = torrent.files.find(function (file) {
      console.log(file);

      return file.name.endsWith('.mp4')
    })

    // Display the file by adding it to the DOM.
    // Supports video, audio, image files, and more!
    file.appendTo('body')
  })

When I have the working torrentId the video loads as expected. When I sub it out with the magnet url that was created via the webtorrent-hybrid package I first get some errors:

WebSocket connection to 'wss://tracker.fastcast.nz/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

Great, so I remove that tracker from the querystring, try again:

WebSocket connection to 'wss://tracker.btorrent.xyz/' failed: Unknown reason

Great, remove it again I get something that just hangs and nothing happens.

If I use the magnet on Brave it just hangs at Loading the torrent file list and the spinner endlessly spins.

What's going on? Thanks

vijayanandnandam commented 4 years ago

@mayeaux i think both trackers are down. Even openwebtorrent.com is overloaded at times and timeouts. You have to setup own tracker for reliability. Check https://github.com/webtorrent/bittorrent-tracker. You can use nginx for ssl termination and proxy the websocket requests to tracker behind

mayeaux commented 4 years ago

Thanks @vijayanandnandam . Are there any tutorials/examples of this already setup? If we are assuming that none of the trackers work (which seems to be the case) then I assume that there should be good tutorials made on how to complete this step (setting up a tracker) since it now seems like a requirement if you want the module to work, thanks.

vijayanandnandam commented 4 years ago

@mayeaux check this gist https://gist.github.com/vijayanandnandam/8e885aba70de6870198bcad0f9396416

It gives a rough idea on what do. You still have to configure nginx properly for ssl termination

mayeaux commented 4 years ago

Thanks. Is there any way for me to test this locally? I did more research yesterday and it looks like perhaps my router is blocking incoming traffic over WebSockets, I wish I could expose my localhost port via something like ngrok but it seems like webtorrent-hybrid uses a random port on boot and it can't be specified. I have a 1.4k star Github project I would like to incorporate WebTorrent with but if there's not a good solution for being able to test the functionality locally and it requires a public server with a public IP (and there's no good workarounds) then that makes the flow of me incorporating the functionality way more difficult and makes me far more reluctant to incorporate WebTorrent into my app since it won't "just work" out of the box. Thanks for your help.

tudor-pop commented 4 years ago

maybe related to https://github.com/webtorrent/webtorrent-hybrid/issues/116 Summary: calling .add(magnetUri) more than 2 times hangs nodejs webtorrent-hybrid because there are too many Peers created. On my computer MacOS latest version, any LTS Nodejs, webtorrent-hybrid hangs when internally are created more than 8 peers. The issue is with Webtorrent-tracker client. First call creates 10 peers -> 1 hybrid node is ok, second .add call creates another 10 peers -> same hybrid node which hangs...add a couple of more torrents and node will sigfault.

stale[bot] commented 4 years ago

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

mayeaux commented 4 years ago

I couldn't get it to work so I gave up.

sergethompson commented 3 years ago

Not sure why this does not work but webtorrent desktop works fine with lots of torrents, kind of an interesting. Seems like if one works fine the other should as well. Anyone have any insight on this?

59023g commented 3 years ago

@sergethompson I'm in the same boat.

feross commented 3 years ago

This issue may be fixed by fixing this issue: https://github.com/webtorrent/webtorrent-hybrid/issues/118 Anyone up to try it out and send a PR?

github-actions[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

sergethompson commented 2 years ago

From what I could investigate this seemed to be an issue pertaining to a macbook pro intel. When used on a linux box this did not seem to be the case. I do not have any further details than that.

github-actions[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?