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

Trying to build a simple demo, and it doesn't work. With logs and errors. #307

Closed
hugomarisco opened this issue May 6, 2015 · 2 comments
Closed

Comments

@hugomarisco
Copy link

@hugomarisco hugomarisco commented May 6, 2015

Hello, first of all, congratz for the great project.

I would really like to get involved in the project and as so, I'm planning to build a simple page showing off the early features already implemented.

Problems I've faced so far:

  • I've tried to seed the file through webtorrent command-line utility, everything seemed to work on that side, but when I try to get it played on the client side, nothing happens.

webtorrent seed FILE.mp4 log

seeding: Suits.S04E16.HDTV.x264-ASAP.mp4

seeding: Suits.S04E16.HDTV.x264-ASAP.mp4

seeding: Suits.S04E16.HDTV.x264-ASAP.mp4
magnet uri: magnet:?xt=urn:btih:cda885686ddb4ca85bf4bebb09b8e5ddf41670f0&dn=Suits.S04E16.HDTV.x264-ASAP.mp4&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80&tr=wss%3A%2F%2Ftracker.webtorrent.io
speed: 0 B/s  downloaded: 0 B/298.08 MB  uploaded: 0 B  peers: 0/0  hotswaps: 0
time remaining: 9 years remaining  total time: 1153s  queued peers: 0  blocked: 0

stream.js (included after webtorrent.min.js)

var client = new WebTorrent()
var magnetUri = "magnet:?xt=urn:btih:cda885686ddb4ca85bf4bebb09b8e5ddf41670f0"

client.add(magnetUri, function (torrent) {
  // Got torrent metadata!
  console.log('Torrent info hash:', torrent.infoHash)

  // Let's say the first file is a webm (vp8) or mp4 (h264) video...
  var file = torrent.files[0]

  // Create a video element
  var video = document.createElement('video')
  video.controls = true
  document.body.appendChild(video)

  // Stream the video into the video tag
  file.createReadStream().pipe(video)
})

client-side test

  • Scripts load and parse without issues
  • Websocket connection is opened to tracker.webtorrent.io
  • Those are the messages exchanged:
{"numWant":5,"uploaded":0,"downloaded":0,"event":"started","info_hash":"ͨ�hmÛL¨[ô¾»\t¸åÝô\u0016pð","peer_id":"-WW0037-3cc9c8a21cd5","offers":[{"offer":{"type":"offer","sdp":"v=0\r\no=- 2992678952953535362 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 59871 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 59871 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 53356 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:KEY2Ksmi7dekmJvJ\r\na=ice-pwd:AOlafKKmygkNzwWxKdyONkru\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"[ðÔ\u001e(_åÆ&%ª8\u0010Oí³ÑÀ[\r"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 5779192017234635252 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 60132 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 60132 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 51914 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:zhJjih5yOILvqW+i\r\na=ice-pwd:Iq+W1xgeyYzC6L3TZBX8pCBS\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"øû\u0010\u000ed®e�×4~\u0000�U'\u001b8¬a�"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 6189784069061228840 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 53061 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 53061 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 55444 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:/SdT7GyL2f7M2Ks3\r\na=ice-pwd:tQF32B3EwH+HDCReUziUoe1Z\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"¾&\u0001¶´&»@n¹���4ð?�ÎÅ\u000f"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 3600893919356709312 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 61356 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 61356 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 54469 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:H8dzm+qlkHEpY0ZB\r\na=ice-pwd:0CvMrXLcXM0EwA+aUH2Era85\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"\u0001}Î�XDMz¦VÌ�vLøÓµ´.µ"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 1207984570614273536 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 55244 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 55244 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 63223 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:/WBZ31rhhOjokVfR\r\na=ice-pwd:k3EGIN1v2O5fWN+fBSemZQER\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"æ+Ö\u000fº��àÅÜs\u000b��KYm¸ËØ"}]}
{"complete":0,"incomplete":1,"action":1,"interval":600000,"info_hash":"cda885686ddb4ca85bf4bebb09b8e5ddf41670f0"}
  • Nothing else really happens (understandable, since it's not finding the seeding peer..)

Then I've tried to create a client-side seeder.

seed.js (after including the webtorrent.min.js)

var client = new WebTorrent();

// When user drops files on the browser, create a new torrent and start seeding it!
client.seed("/Users/hugomarisco/projects/webtorrent/Suits.S04E16.HDTV.x264-ASAP.mp4", function onTorrent (torrent) {
  // Client is seeding the file!
  console.log('Torrent info hash:', torrent.infoHash);
});

client-side test

  • Error on webtorrent.min.js:
Uncaught TypeError: u.readdir is not a function

Tried to change the path to an single element array, same outcome.

Finally I've tried to use instant.io to seed the file and use my streaming client to test it.

With a file of ~298MB, after choosing it, page goes blank and interaction hangs (seems like a crash)

With a smaller file (~5MB), it does load and I can stream it to other instant.io pages (seed/leech/stream works smoothly).

But when trying to do the same thing with my previous stream code (changing the magnet link to magnet:?xt=urn:btih:1d33ce4f186e79894aa615b511dc7af0d1de55b3 - the one stated in instant.io), I get the following:

{"numWant":5,"uploaded":0,"downloaded":0,"event":"started","info_hash":"\u001d3ÎO\u0018ny�J¦\u0015µ\u0011ÜzðÑÞU³","peer_id":"-WW0037-715d4b958c6f","offers":[{"offer":{"type":"offer","sdp":"v=0\r\no=- 6994251555641597528 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 61090 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 61090 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 62740 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:vkyFh+ieIWXAR6NT\r\na=ice-pwd:rNan6Rej916c7ZT10gG1uGCo\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"ï»­4âkòÂßVDu�ý©NÂýË]"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 2342123792716068175 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 54893 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 54893 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 61032 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:OXGDANbSQFuQo6V5\r\na=ice-pwd:7UDaBCCu6/qNr8D0TT15hWte\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"�\u000bòiTßz$cËWe\u000e5q�S×\u0006ÿ"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 3268375399971576220 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 51468 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 51468 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 61132 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:VVD5df9QDpRAqTC2\r\na=ice-pwd:Bxs6KyWHiwciQSobYPEfSWAo\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"ü¤\u0001Láâæ\u0003�®�X�\u001d÷ {[YÓ"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 6906449609333566609 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 58741 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 58741 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 60516 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:7YjhCOm+QpiIG3C6\r\na=ice-pwd:a1rjZeel+dfgAWz6Y0Ou5Cw/\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"¹¥¨|AFY\u0019!l �¹\u001e;®Æ»3*"},{"offer":{"type":"offer","sdp":"v=0\r\no=- 5665255096806655265 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 63674 DTLS/SCTP 5000\r\nc=IN IP4 192.168.10.1\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 63674 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 61339 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=ice-ufrag:qO1f2zaI4TZCRO9D\r\na=ice-pwd:UYYdhydz79bY6YmzO5FYN5In\r\na=fingerprint:sha-256 AD:52:42:88:C9:AD:4B:46:9B:87:B7:71:37:77:0C:BE:3D:01:7F:F8:D5:35:2A:78:39:3E:D9:1B:D5:54:C4:CE\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"fà�ù¢5�+fÊ\u0017�óÇZ/çÅÜÃ"}]}
{"complete":1,"incomplete":1,"action":1,"interval":600000,"info_hash":"1d33ce4f186e79894aa615b511dc7af0d1de55b3"}
{"answer":{"type":"answer","sdp":"v=0\r\no=- 413591515700819524 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 18815 DTLS/SCTP 5000\r\nc=IN IP4 52.17.151.248\r\nb=AS:1638400\r\na=candidate:2430253621 1 udp 2122260223 192.168.10.1 52150 typ host generation 0\r\na=candidate:704553097 1 udp 2122194687 192.168.1.3 58629 typ host generation 0\r\na=candidate:3730392773 1 tcp 1518280447 192.168.10.1 0 typ host tcptype active generation 0\r\na=candidate:1736268921 1 tcp 1518214911 192.168.1.3 0 typ host tcptype active generation 0\r\na=candidate:2158047068 1 udp 1685987071 213.22.43.161 58629 typ srflx raddr 192.168.1.3 rport 58629 generation 0\r\na=candidate:2519116379 1 udp 41819903 52.17.151.248 18815 typ relay raddr 213.22.43.161 rport 58629 generation 0\r\na=ice-ufrag:tmWbc5HuVywnnEcw\r\na=ice-pwd:2EOOMi+5XSySuzqnlOs/fJ/U\r\na=fingerprint:sha-256 66:BE:76:32:1E:87:29:9A:CD:96:2F:A2:52:F8:F8:A0:17:BF:94:26:D8:B2:3B:41:42:EC:0F:B1:68:D7:92:A8\r\na=setup:active\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"},"offer_id":"ï»­4âkòÂßVDu�ý©NÂýË]","peer_id":"-WW0037-00d88b3b5616","info_hash":"\u001d3ÎO\u0018ny�J¦\u0015µ\u0011ÜzðÑÞU³"}

So, everything seems to work, but nothing really happens. Nothing is appended to body, no errors, nothing.

There is probably something missing within my approach to get this work and I thank you in advance for any guidelines.

Hoping to make this grow and get to a point where it becomes a standard for major bittorrent clients.

Best regards

@hugomarisco hugomarisco changed the title "Big" files crash instant.io Trying to build a simple demo, and it doesn't work. With logs and errors. May 6, 2015
@jakefb

This comment has been minimized.

Copy link
Contributor

@jakefb jakefb commented May 7, 2015

Hi, Webtorrent no longer includes the wrtc module, you will have to use webtorrent-hybrid to connect to web peers. As far as I know the path of the file you want to seed, should be a buffer for it to work in the browser. You can convert an array to a buffer like this:

function onFile (err, results) {
  var files = results.map(function (r) {
    var buf = toBuffer(new Uint8Array(r.target.result))
    buf.name = r.file.name
    buf.size = r.file.size
    buf.lastModifiedDate = r.file.lastModifiedDate
    buf.type = r.file.type
    return buf
  })
  // Seed the files
  client.seed(files)
}

What browser are you using for instant.io? I have problems seeding large files with instant.io. The electron app I'm developing for my website solves the issue of easily seeding multiple videos for me https://github.com/jakefb/fastcast-app. I think this issue is actually related to the code above; loading a large file into the memory can crash the browser.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 8, 2015

WebTorrent does not condone copyright infringement. Please don't open issues that contain torrent or tracker names. This violates our contributor guidelines.

@feross feross closed this May 8, 2015
@webtorrent webtorrent locked and limited conversation to collaborators May 8, 2015
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.