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

[CLOSED] Only the first part (32kb) is being downloaded from a file #129

Closed
feross opened this issue Sep 21, 2014 · 5 comments
Closed

[CLOSED] Only the first part (32kb) is being downloaded from a file #129

feross opened this issue Sep 21, 2014 · 5 comments

Comments

@feross
Copy link
Member

@feross feross commented Sep 21, 2014

Issue by marmolejo
Monday Jul 07, 2014 at 19:47 GMT
Originally opened as https://github.com/feross/bittorrent-client/issues/33


If I copy the example from the usage README.md and pipe the result to stdout, I see only the first 32kb of each file being printed. I'm noting that whole files are being downloaded, but only the first part is stored.

var BitTorrentClient = require('bittorrent-client')

var client = BitTorrentClient()

// "Pride and Prejudice" by Jane Austen
client.add('magnet:?xt=urn:btih:1e69917fbaa2c767bca463a96b5572785c6d8a12')

client.on('torrent', function (torrent) {
  // torrent metadata has been fetched
  console.log(torrent.name)

  torrent.files.forEach(function (file) {
    console.log(file.name)
    // get a readable stream of the file content
    var stream = file.createReadStream().pipe(process.stdout)
  })
})
@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Sep 21, 2014

Comment by feross
Thursday Jul 10, 2014 at 08:36 GMT


Hmm, you're right. Something fishy is going on. I modified the example to only print out the first file:

var BitTorrentClient = require('./')
var client = BitTorrentClient()
client.add('magnet:?xt=urn:btih:1e69917fbaa2c767bca463a96b5572785c6d8a12')
client.on('torrent', function (torrent) {
  torrent.files[0].createReadStream().pipe(process.stdout)
})

and ran it with node example.js > file.epub and only 64KB gets saved. Not sure what's wrong but I'll look into it.

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Sep 21, 2014

Comment by feross
Wednesday Jul 23, 2014 at 06:16 GMT


Got another report of this:

$ DEBUG=* node single.js
  bittorrent-swarm Connecting to 10.42.0.1:51413 +0ms (numConns 0 numPeers 0)
  bittorrent-client Swarm listening on port 9355 +5ms
  bittorrent-client got peer via ut_pex 10.42.0.31:33470 +3s
  bittorrent-swarm Connecting to 10.42.0.31:33470 +1ms (numConns 1 numPeers 1)
  bittorrent-swarm Failed to connect to 10.42.0.31:33470 +1ms
  bittorrent-client got piece 66(offset: 0 length: 16384) from 10.42.0.1:51413 +3s
  bittorrent-client got piece 0(offset: 0 length: 16384) from 10.42.0.1:51413 +497ms
  bittorrent-client got piece 0(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 0 (66 still missing) +8ms
  bittorrent-client got piece 1(offset: 0 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client got piece 1(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 1 (65 still missing) +6ms
  bittorrent-client got piece 2(offset: 0 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client got piece 2(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 2 (64 still missing) +6ms
  bittorrent-client got piece 3(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 3(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 3 (63 still missing) +5ms
  bittorrent-client got piece 4(offset: 0 length: 16384) from 10.42.0.1:51413 +4ms
  bittorrent-client got piece 4(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 4 (62 still missing) +4ms
  bittorrent-client got piece 5(offset: 0 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client got piece 5(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 5 (61 still missing) +7ms
  bittorrent-client got piece 6(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 6(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 6 (60 still missing) +5ms
  bittorrent-client got piece 7(offset: 0 length: 16384) from 10.42.0.1:51413 +393ms
  bittorrent-client got piece 7(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 7 (59 still missing) +6ms
  bittorrent-client got piece 8(offset: 0 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client got piece 8(offset: 16384 length: 16384) from 10.42.0.1:51413 +12ms
  bittorrent-client piece done 8 (58 still missing) +7ms
  bittorrent-client got piece 9(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 9(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 9 (57 still missing) +7ms
  bittorrent-client got piece 10(offset: 0 length: 16384) from 10.42.0.1:51413 +444ms
  bittorrent-client got piece 10(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 10 (56 still missing) +8ms
  bittorrent-client got piece 11(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 11(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 11 (55 still missing) +10ms
  bittorrent-client got piece 12(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 12(offset: 16384 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client piece done 12 (54 still missing) +5ms
  bittorrent-client got piece 13(offset: 0 length: 16384) from 10.42.0.1:51413 +457ms
  bittorrent-client got piece 13(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 13 (53 still missing) +12ms
  bittorrent-client got piece 14(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 14(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 14 (52 still missing) +8ms
  bittorrent-client got piece 15(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 15(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 15 (51 still missing) +7ms
  bittorrent-client got piece 16(offset: 0 length: 16384) from 10.42.0.1:51413 +450ms
  bittorrent-client got piece 16(offset: 16384 length: 16384) from 10.42.0.1:51413 +10ms
  bittorrent-client piece done 16 (50 still missing) +11ms
  bittorrent-client got piece 17(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 17(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 17 (49 still missing) +10ms
  bittorrent-client got piece 18(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 18(offset: 16384 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client piece done 18 (48 still missing) +7ms
  bittorrent-client got piece 19(offset: 0 length: 16384) from 10.42.0.1:51413 +450ms
  bittorrent-client got piece 19(offset: 16384 length: 16384) from 10.42.0.1:51413 +14ms
  bittorrent-client piece done 19 (47 still missing) +9ms
  bittorrent-client got piece 20(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 20(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 20 (46 still missing) +9ms
  bittorrent-client got piece 21(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 21(offset: 16384 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client piece done 21 (45 still missing) +7ms
  bittorrent-client got piece 22(offset: 0 length: 16384) from 10.42.0.1:51413 +450ms
  bittorrent-client got piece 22(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 22 (44 still missing) +11ms
  bittorrent-client got piece 23(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 23(offset: 16384 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client piece done 23 (43 still missing) +8ms
  bittorrent-client got piece 24(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 24(offset: 16384 length: 16384) from 10.42.0.1:51413 +475ms
  bittorrent-client piece done 24 (42 still missing) +11ms
  bittorrent-client got piece 25(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 25(offset: 16384 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client piece done 25 (41 still missing) +6ms
  bittorrent-client got piece 26(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 26(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 26 (40 still missing) +10ms
  bittorrent-client got piece 27(offset: 0 length: 16384) from 10.42.0.1:51413 +459ms
  bittorrent-client got piece 27(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 27 (39 still missing) +10ms
  bittorrent-client got piece 28(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 28(offset: 16384 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client piece done 28 (38 still missing) +6ms
  bittorrent-client got piece 29(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 29(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 29 (37 still missing) +9ms
  bittorrent-client got piece 30(offset: 0 length: 16384) from 10.42.0.1:51413 +455ms
  bittorrent-client got piece 30(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 30 (36 still missing) +11ms
  bittorrent-client got piece 31(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 31(offset: 16384 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client piece done 31 (35 still missing) +7ms
  bittorrent-client got piece 32(offset: 0 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client got piece 32(offset: 16384 length: 16384) from 10.42.0.1:51413 +471ms
  bittorrent-client piece done 32 (34 still missing) +11ms
  bittorrent-client got piece 33(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 33(offset: 16384 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client piece done 33 (33 still missing) +11ms
  bittorrent-client got piece 34(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 34(offset: 16384 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client piece done 34 (32 still missing) +10ms
  bittorrent-client got piece 35(offset: 0 length: 16384) from 10.42.0.1:51413 +469ms
  bittorrent-client got piece 35(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 35 (31 still missing) +10ms
  bittorrent-client got piece 36(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 36(offset: 16384 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client piece done 36 (30 still missing) +7ms
  bittorrent-client got piece 37(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 37(offset: 16384 length: 16384) from 10.42.0.1:51413 +470ms
  bittorrent-client piece done 37 (29 still missing) +9ms
  bittorrent-client got piece 38(offset: 0 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client got piece 38(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 38 (28 still missing) +12ms
  bittorrent-client got piece 39(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 39(offset: 16384 length: 16384) from 10.42.0.1:51413 +2ms
  bittorrent-client piece done 39 (27 still missing) +10ms
  bittorrent-client got piece 40(offset: 0 length: 16384) from 10.42.0.1:51413 +463ms
  bittorrent-client got piece 40(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 40 (26 still missing) +10ms
  bittorrent-client got piece 41(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 41(offset: 16384 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client piece done 41 (25 still missing) +6ms
  bittorrent-client got piece 42(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 42(offset: 16384 length: 16384) from 10.42.0.1:51413 +475ms
  bittorrent-client piece done 42 (24 still missing) +11ms
  bittorrent-client got piece 43(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 43(offset: 16384 length: 16384) from 10.42.0.1:51413 +2ms
  bittorrent-client piece done 43 (23 still missing) +10ms
  bittorrent-client got piece 44(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 44(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 44 (22 still missing) +9ms
  bittorrent-client got piece 45(offset: 0 length: 16384) from 10.42.0.1:51413 +458ms
  bittorrent-client got piece 45(offset: 16384 length: 16384) from 10.42.0.1:51413 +14ms
  bittorrent-client piece done 45 (21 still missing) +11ms
  bittorrent-client got piece 46(offset: 0 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client got piece 46(offset: 16384 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client piece done 46 (20 still missing) +6ms
  bittorrent-client got piece 47(offset: 0 length: 16384) from 10.42.0.1:51413 +2ms
  bittorrent-client got piece 47(offset: 16384 length: 16384) from 10.42.0.1:51413 +458ms
  bittorrent-client piece done 47 (19 still missing) +10ms
  bittorrent-client got piece 48(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 48(offset: 16384 length: 16384) from 10.42.0.1:51413 +4ms
  bittorrent-client piece done 48 (18 still missing) +6ms
  bittorrent-client got piece 49(offset: 0 length: 16384) from 10.42.0.1:51413 +2ms
  bittorrent-client got piece 49(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 49 (17 still missing) +10ms
  bittorrent-client got piece 50(offset: 0 length: 16384) from 10.42.0.1:51413 +462ms
  bittorrent-client got piece 50(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 50 (16 still missing) +8ms
  bittorrent-client got piece 51(offset: 0 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client got piece 51(offset: 16384 length: 16384) from 10.42.0.1:51413 +9ms
  bittorrent-client piece done 51 (15 still missing) +6ms
  bittorrent-client got piece 52(offset: 0 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client got piece 52(offset: 16384 length: 16384) from 10.42.0.1:51413 +455ms
  bittorrent-client piece done 52 (14 still missing) +10ms
  bittorrent-client got piece 53(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 53(offset: 16384 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client piece done 53 (13 still missing) +7ms
  bittorrent-client got piece 54(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 54(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 54 (12 still missing) +8ms
  bittorrent-client got piece 55(offset: 0 length: 16384) from 10.42.0.1:51413 +538ms
  bittorrent-client got piece 55(offset: 16384 length: 16384) from 10.42.0.1:51413 +22ms
  bittorrent-client piece done 55 (11 still missing) +8ms
  bittorrent-client got piece 56(offset: 0 length: 16384) from 10.42.0.1:51413 +57ms
  bittorrent-client got piece 56(offset: 16384 length: 16384) from 10.42.0.1:51413 +20ms
  bittorrent-client piece done 56 (10 still missing) +5ms
  bittorrent-client got piece 57(offset: 0 length: 16384) from 10.42.0.1:51413 +66ms
  bittorrent-client got piece 57(offset: 16384 length: 16384) from 10.42.0.1:51413 +252ms
  bittorrent-client piece done 57 (9 still missing) +17ms
  bittorrent-client got piece 58(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 58(offset: 16384 length: 16384) from 10.42.0.1:51413 +0ms
  bittorrent-client piece done 58 (8 still missing) +3ms
  bittorrent-client got piece 59(offset: 0 length: 16384) from 10.42.0.1:51413 +34ms
  bittorrent-client got piece 59(offset: 16384 length: 16384) from 10.42.0.1:51413 +60ms
  bittorrent-client piece done 59 (7 still missing) +5ms
  bittorrent-client got piece 60(offset: 0 length: 16384) from 10.42.0.1:51413 +373ms
  bittorrent-client got piece 60(offset: 16384 length: 16384) from 10.42.0.1:51413 +8ms
  bittorrent-client piece done 60 (6 still missing) +6ms
  bittorrent-client got piece 61(offset: 0 length: 16384) from 10.42.0.1:51413 +2ms
  bittorrent-client got piece 61(offset: 16384 length: 16384) from 10.42.0.1:51413 +10ms
  bittorrent-client piece done 61 (5 still missing) +5ms
  bittorrent-client got piece 62(offset: 0 length: 16384) from 10.42.0.1:51413 +1ms
  bittorrent-client got piece 62(offset: 16384 length: 16384) from 10.42.0.1:51413 +471ms
  bittorrent-client piece done 62 (4 still missing) +5ms
  bittorrent-client got piece 63(offset: 0 length: 16384) from 10.42.0.1:51413 +3ms
  bittorrent-client got piece 63(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 63 (3 still missing) +5ms
  bittorrent-client got piece 64(offset: 0 length: 16384) from 10.42.0.1:51413 +5ms
  bittorrent-client got piece 64(offset: 16384 length: 16384) from 10.42.0.1:51413 +7ms
  bittorrent-client piece done 64 (2 still missing) +5ms
  bittorrent-client got piece 65(offset: 0 length: 16384) from 10.42.0.1:51413 +464ms
  bittorrent-client got piece 65(offset: 16384 length: 16384) from 10.42.0.1:51413 +6ms
  bittorrent-client piece done 65 (1 still missing) +4ms
  bittorrent-client got piece 66(offset: 16384 length: 9907) from 10.42.0.1:51413 +0ms
  bittorrent-client piece done 66 (0 still missing) +7ms
  bittorrent-client file done index.html +0ms
  bittorrent-client FILE +0ms index.html
  bittorrent-client torrent d69117b5ca7d3a6653299cf0a513e6bd10953230 done +1ms
torrent downloaded successfully!

It seems it's downloading the 66 pieces according to this log, unfortunately the output file is only 32 Kb long. I don't see anything wrong here. Maybe there is a way to increase the debug level for the log?

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Sep 21, 2014

Comment by feross
Sunday Aug 17, 2014 at 11:37 GMT


Finally figured out what was causing this bug. Sorry it took so long. It works now!

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Sep 21, 2014

Comment by feross
Sunday Aug 17, 2014 at 11:46 GMT


Published new version as 0.7.0.

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Sep 21, 2014

Comment by marmolejo
Wednesday Aug 20, 2014 at 20:25 GMT


Oh yes!

I have tried it and it is finally working!

Thanks :)

2014-08-17 13:46 GMT+02:00 Feross Aboukhadijeh notifications@github.com:

Published new version as 0.7.0.

Reply to this email directly or view it on GitHub
https://github.com/feross/bittorrent-client/issues/33#issuecomment-52419813
.

Zeus Gómez Marmolejo
Zet - The x86 (IA-32) open implementation
http://zet.aluzina.org

@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2018
This issue was closed.
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
1 participant
You can’t perform that action at this time.