1

I tried finding it out, but couldn't. I am following the steps from here — https://webtorrent.io/intro. I have following code in the file.

<html>
<head>
<title>
StreamTest
</title>
<script type="text/javascript" src="webtorrent.min.js"></script>

<script>
var client = new WebTorrent()

var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

client.add(torrentId, function (torrent) {
  // Torrents can contain many files. Let's use the first.
  var file = torrent.files[0]

  // Display the file by adding it to the DOM. Supports video, audio, image,     etc. files
  file.appendTo('body')
})
</script>
</head>
<body>
<h2>Torrent Stream Test</h2>
</body>
</html>

This code works fine with infohash — 6a9759bffd5c0af65319979fb7832189f4f3c35d But when I use it other info hash or magnet link, it doesn't work. An example of other info hash is 80096C11147EEE4D2B6B6AC0B96C951E48298BE3

Any idea, why doesn't it work with other infohash or magnet link?

  • 2
    WebTorrent in the browser will only work with WebRTC seeded torrents or those torrents which have a valid WebTorrent webseed. Unfortunately, TCP/UDP connections cannot be done natively in JS so connecting to normal TCP/UDP peers is not possible unless you use a browser extension. (I'm a WebTorrent project collaborator) – DiegoRBaquero Feb 10 '16 at 9:25
  • @DiegoRBaquero Could I do this: host a nodejs server that use WebTorrent as a seed server, then connect to the server made by this nodejs. – holmescn Apr 22 '17 at 5:53
  • @holmescn Yes, with webtorrent-hybrid, although I recommend using webseeds. – DiegoRBaquero Apr 24 '17 at 19:15
  • @DiegoRBaquero Can you expand a little on the use of webseeds ? Let's say I take a magnet link of the web, would it imply downloading it first and then seeding it using a webrtc client ? – Stanislasdrg Reinstate Monica Apr 12 '18 at 13:34
  • @Stanislasdrg To create a webseed, yes, you would need to have the content first and creating the webseed, uploading it somewhere public. – DiegoRBaquero Apr 13 '18 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.