javascriptwebtorrent

Does not download a file by magnet links


This is an example from the documentation.

var client = new WebTorrent()

var torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&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%2Fsintel.torrent'

client.add(torrentId, function (torrent) {
  // Torrents can contain many files. Let's use the .mp4 file
  //var file = torrent.files.find(function (file) {
  //return file.name.endsWith('.mp4')
  //})
  // no console.log !!
  console.log(torrent)
  // Display the file by adding it to the DOM. Supports video, audio, image, etc. files
  torrent.files[0].appendTo('body')
})

An example works well. But if I change the magnet link to another but nothing happens. The link to which I am changing is valid.

magnet:?xt=urn:btih:C45CE38E4508E775E49EB2A6841C814D1A8AD375&tr=http%3A%2F%2Fbt3.t-ru.org%2Fann%3Fmagnet

but does not work with this link. Not a single mistake or nothing at all


Solution

  • I have had similar issues recently trying to work this out. Only instant.io (using a turn server) consistently works. Very little webRTC stuff works for me.

    I think the reason the template provided by WebTorrent works and no others is because the model contains a magnet which has a link to the torrent file on their website.

    I suspect they are seeding it or even just providing it via some other means.

    xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent

    Whoever created instant.io took the web torrent template and made it work. WebRTC is an absolute nightmare, and the web torrent template/site doesn't even get the WebSocket connections right (for me, at least).

    If you are looking to pass on relatively small amounts of data, then relaying via your WebSockets is far more manageable.

    If you want to create something like WebTorrent, that works look at instant.io's Github. You'll need to set up a server and configure a turn server. WebRTC is like trying to configure a graphics card in 1992. Good luck.