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

Torrent not being added #1109

Closed
tiagommferreira opened this issue Apr 20, 2017 · 3 comments
Closed

Torrent not being added #1109

tiagommferreira opened this issue Apr 20, 2017 · 3 comments

Comments

@tiagommferreira
Copy link

@tiagommferreira tiagommferreira commented Apr 20, 2017

What version of WebTorrent?
0.98.18

What operating system and Node.js version?
Ubuntu 16.04.2 LTS
Node.js v7.9.0

What did you expect to happen?
I expected the example code (shown bellow) to download the torrent to the destination folder

var WebTorrent = require('webtorrent')

var client = new WebTorrent()

var magnetURI = 'https://webtorrent.io/torrents/sintel.torrent'

client.add(magnetURI, { path: '/path/to/folder' }, function (torrent) {
  console.log("Downloaded torrent metadata")
  torrent.on('done', function () {
    console.log('torrent download finished')
    clearInterval(interval);
  })
  var interval = setInterval(onProgress, 500)
  onProgress()

  // Statistics
  function onProgress () {
      // Peers
      console.log(torrent.numPeers + (torrent.numPeers === 1 ? ' peer' : ' peers'))

      // Progress
      var percent = Math.round(torrent.progress * 100 * 100) / 100
      console.log("Percentage: " + percent + "%")
      console.log("Downloaded: " + prettyBytes(torrent.downloaded))

      // Speed rates
      console.log("Download Speed: " + prettyBytes(torrent.downloadSpeed) + '/s')
  }

})

// Human readable bytes util
function prettyBytes(num) {
  var exponent, unit, neg = num < 0, units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
  if (neg) num = -num
  if (num < 1) return (neg ? '-' : '') + num + ' B'
  exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1)
  num = Number((num / Math.pow(1000, exponent)).toFixed(2))
  unit = units[exponent]
  return (neg ? '-' : '') + num + ' ' + unit
}

What actually happened?
Torrent is not being downloaded, code in the client add function is not being called.

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Apr 20, 2017

It does work for me.

Can you please run the code with the env variable DEBUG set to *?

You can do this with the following command: DEBUG=* node myFile.js

@tiagommferreira

This comment has been minimized.

Copy link
Author

@tiagommferreira tiagommferreira commented Apr 20, 2017

@DiegoRBaquero The output of that command in this file

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 21, 2018

This issue appears stale since it has been open for a while with no activity. I'm going to close it for now. If this is still issue, please feel free to leave a comment or open a new issue.

@feross feross closed this Apr 21, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 20, 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.