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

Seeding/downloading #732

Closed
Tercus opened this issue Apr 7, 2016 · 5 comments
Closed

Seeding/downloading #732

Tercus opened this issue Apr 7, 2016 · 5 comments
Labels

Comments

@Tercus
Copy link
Contributor

@Tercus Tercus commented Apr 7, 2016

  • WebTorrent version: 0.86.1 (win7) / 0.90.2 (linux)
  • Node.js version: 5.8.0 (win7) / 5.10.1 (Linux)

I am trying to seed a file and download that file, but I fail to get it to work. Especially Windows is making it very very hard.

I have two scripts, one for seeding and one for downloading:

var WebTorrent = require('webtorrent')
var client = new WebTorrent()
var file = 'testfile.jpg'

client.seed(file, function (torrent) {
    console.log('Seeding: ' + file)
    console.log(torrent.infoHash)
})
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
var fs = require('fs')

//manually add the infoHash
download = 'b8fee5e1dc746256587df78879d440c3979af750'
console.log('download: ' + download)
client.add(download, { path: '/download/' }, function (torrent) {
    console.log('added torrent')
    torrent.files.forEach(function (file) {
        console.log('Started saving ' + file.name)
        file.getBuffer(function (err, buffer) {
            if (err) {
                console.error('Error downloading ' + file.name)
                return
            }
                fs.writeFile(file.name, buffer, function (err) {
                console.error('Error saving ' + file.name)
            })
        })
    })
})

neither one is showing any errors and yet neither one is working in windows. These are the tests I made:

In linux:

  • Use scripts as shown -> failed
  • Use webtorrent-hybrid instead of webtorrent -> worked
  • Use instant.io to seed files and download with script (webtorrent-hybrid) -> worked
  • Use script to seed file (webtorrent-hybrid) and download with instant.io -> worked

In windows

  • Use scripts as shown -> failed
  • Use webtorrent-hybrid instead of webtorrent -> failed
  • Use instant.io to seed files and download with script (webtorrent-hybrid) -> failed
  • Use script to seed file (webtorrent-hybrid) and download with instant.io -> failed
  • Use download script to get random torrent (sintel-torrent from webtorrent.io) -> worked

I am working behind two routers, but Linux is within a VM and still seems to work, so that can't be it?
Are there any errors in my code, or are there any more tests I could do?

@Tercus

This comment has been minimized.

Copy link
Contributor Author

@Tercus Tercus commented Apr 8, 2016

I changed the download test-code a bit and tried a few other things:

var WebTorrent = require('webtorrent-hybrid')
var client = new WebTorrent()
var fs = require('fs')

var sintel = 'https://webtorrent.io/torrents/sintel.torrent'
var magnet = 'magnet:?xt=urn:btih:c3ac6be00f67c88118c71e4971d12c793b99b954&dn=LtUxcQ1.jpg&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io'

var download = magnet
console.log('download: ' + download)
client.add(download, { path: './download/' }, function (torrent) {
    console.log('added torrent')
})
client.on('torrent', function(torrent) {
    console.log('Established connection')
    torrent.on('done', function() {
        console.log('Finished downloading file')
    })
    torrent.on('download', function(chunksize) {
        console.log('progress: ' + torrent.progress)
    })
})
  • Use code to download sintel -> worked
  • Use code to download magnet link (instant.io) -> failed

I then went on and tried the webtorrent-desktop app to try and download the exact same magnet link. It took quite a bit of time to connect, but worked in the end.

@Tercus

This comment has been minimized.

Copy link
Contributor Author

@Tercus Tercus commented Apr 8, 2016

I tried copying the method with which webtorrent-desktop is able to download the torrent. So far I haven't managed it, but I did learn a few things and got a few error-messages that were missing before.
New code I used:

var WebTorrent = require('webtorrent-hybrid')
var client = new WebTorrent()
var fs = require('fs')

var sintel = 'https://webtorrent.io/torrents/sintel.torrent'
var magnet = 'magnet:?xt=urn:btih:c3ac6be00f67c88118c71e4971d12c793b99b954&dn=LtUxcQ1.jpg&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io'

var download = magnet
console.log('download: ' + download)
var torrent = client.add(download, { path: './download/' })
addTorrentEvents(torrent)

function addTorrentEvents(torrent) {
    torrent.on('warning', (err) =>
        console.log('warning: ', err.message))
    torrent.on('error', (err) =>
        console.log('error: ', err.message))
    torrent.on('infoHash', () =>
        console.log('infohash: ', torrent.infoHash))
    torrent.on('metadata', torrentMetadata)
    torrent.on('ready', torrentReady)
    torrent.on('done', torrentDone)

    function torrentMetadata () {
        console.log('metadata received')
    }

    function torrentReady () {
        console.log('Torrent ready to download')
    }

    function torrentDone () {
        console.log('Torrent downloaded')
    }
}

Error-messages I received:

D:\Programming\Projects\web\crowder\tests>node download-test.js

(electron) ipc module is deprecated. Use require("electron").ipcMain instead.
download: magnet:?xt=urn:btih:c3ac6be00f67c88118c71e4971d12c793b99b954&dn=LtUxcQ
1.jpg&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfe
r.tk%3A6969&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftr
acker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A8
0&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%
3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io
infohash:  c3ac6be00f67c88118c71e4971d12c793b99b954
warning:  connection error to wss://tracker.openwebtorrent.com
warning:  tracker request timed out (started) (udp://exodus.desync.com:6969)
warning:  tracker request timed out (started) (udp://tracker.leechers-paradise.o
rg:6969)
warning:  tracker request timed out (started) (udp://tracker.openbittorrent.com:
80)
warning:  connection error to wss://tracker.openwebtorrent.com
warning:  connection error to wss://tracker.openwebtorrent.com
warning:  connection error to wss://tracker.fastcast.nz
warning:  connection error to wss://tracker.fastcast.nz
warning:  connection error to wss://tracker.openwebtorrent.com
warning:  connection error to wss://tracker.fastcast.nz
warning:  connection error to wss://tracker.openwebtorrent.com

so all in all still same behaviour: sintel downloads fine, instant.io fails

@andreapaiola

This comment has been minimized.

Copy link
Contributor

@andreapaiola andreapaiola commented Apr 17, 2016

I noticed that

it's fine with
magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4

This doesn't work
magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d

in the browser

confirmed?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 5, 2016

@andreapaiola That makes sense. You need to use the full magnet link -- not just an info hash -- in order for the WebTorrent script to find peers in the browser. The webtorrent library no longer appends a default list of trackers when you call client.add with no trackers.

@feross feross closed this May 5, 2016
@feross feross added the question label May 5, 2016
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 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.