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

What are the requirements for a torrent file to play in a browser? :) #1648

Closed
Bdoom opened this issue Jun 21, 2019 · 10 comments
Closed

What are the requirements for a torrent file to play in a browser? :) #1648

Bdoom opened this issue Jun 21, 2019 · 10 comments

Comments

@Bdoom
Copy link

@Bdoom Bdoom commented Jun 21, 2019

What version of WebTorrent?
Latest

What operating system and Node.js version?
Mac OSX, I'm not using Node.js.

What browser and version? (if using WebTorrent in the browser)
Chrome
What did you expect to happen?
Video play
What actually happened?
Error

I'm trying to figure out how to get web torrent to play a video, but I'm getting some weird errors.

I'm trying to play videos directly from .torrent files hosted on other websites.

When we go to the chrome console, we get this:

Mixed Content: The page at 'sdasdd/' was loaded over HTTPS, but requested an insecure script 'http://momentjs.com/downloads/moment.min.js'. This request has been blocked; the content must be served over HTTPS.
/favicon.ico:1 Failed to load resource: the server responded with a status of 404 ()
(index):1 Access to XMLHttpRequest at 'fakewebsite.com/torrent.torrent' from origin 'https://fakewebsite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
webtorrent.min.js:4 Uncaught Error: Error downloading torrent: XHR error
    at webtorrent.min.js:5
    at t.exports.<anonymous> (webtorrent.min.js:7)
    at t.exports.t (webtorrent.min.js:5)
    at t.exports.r.emit (webtorrent.min.js:4)
    at XMLHttpRequest.c.onerror (webtorrent.min.js:7)

I also get this:

webtorrent.min.js:6 Uncaught (in promise) DOMException .
o @ webtorrent.min.js:6
@Bdoom Bdoom changed the title broken nyaa.si broken Jun 21, 2019
@Bdoom Bdoom changed the title broken broken in plain html/ruby on rails Jun 21, 2019
@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jun 21, 2019

Also, if I use a magnet link I get no errors, but nothing plays. All of this works in webtorrent desktop, but not on my own html page.

@alxhotel

This comment has been minimized.

Copy link
Member

@alxhotel alxhotel commented Jun 21, 2019

(index):1 Access to XMLHttpRequest at 'fakewebsite.com/torrent.torrent' from origin 'https://fakewebsite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sorry for stating the obvious, but you need to send the Access-Control-Allow-Origin header in the HTTP response of the torrent. (If you are not the owner of the website serving the torrent file, you would have to fetch the torrent through other means)

Also, if I use a magnet link I get no errors, but nothing plays. All of this works in webtorrent desktop, but not on my own html page.

If it works on Webtorrent Desktop and not in the browser, most probably the torrent you are trying to download has no webtorrent peers.

@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jul 7, 2019

(index):1 Access to XMLHttpRequest at 'fakewebsite.com/torrent.torrent' from origin 'https://fakewebsite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sorry for stating the obvious, but you need to send the Access-Control-Allow-Origin header in the HTTP response of the torrent. (If you are not the owner of the website serving the torrent file, you would have to fetch the torrent through other means)

Also, if I use a magnet link I get no errors, but nothing plays. All of this works in webtorrent desktop, but not on my own html page.

If it works on Webtorrent Desktop and not in the browser, most probably the torrent you are trying to download has no webtorrent peers.

Is it possible to load a local .torrent file? I have tried this and this does not work either? Do I need to add my own tracker? If so, how?

@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jul 7, 2019

Also, for some reason, it seems like it won't even load a local .torrent file? No errors in console, it just won't load the video.

@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jul 7, 2019

Interestingly enough, if I try to do: torrent.numPeers and console.log this out, it always is showing 0, but the website with the torrent says it has over 300 seeders.

@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jul 7, 2019

It seems to work in webtorrent terminal interface, but not in a web browser :(

Server running at: http://localhost:8000/0/3bad16d49a621396c9ab6aec04facb960dbf2
Server running at: http://localhost:8000/0/3bad16d49a621396c9ab6aec04facb960dbf2c59/msyaysdaysd.mp4
Downloading to: /Users/me/Desktop/webtorrent-testing

Speed: 128 KB/s Downloaded: 1.7 MB/352 MB Uploaded: 672 KB
Running time: 20 seconds Time remaining: an hour Peers: 4/71

S 172.83.210.200:30937 0 B 0 B/s 0 B/s
S 112.136.111.202:23074 0 B 0 B/s 0 B/s
S 180.14.152.229:25172 0 B 0 B/s 0 B/s
S 182.167.164.147:20002 0 B 0 B/s 0 B/s
S 36.2.238.62:62377 0 B 0 B/s 0 B/s
S 180.6.115.54:18280 0 B 0 B/s 0 B/s
S 124.213.82.120:13584 0 B 0 B/s 0 B/s
S 119.245.157.101:24129 0 B 0 B/s 0 B/s
S 180.198.205.106:58845 0 B 0 B/s 0 B/s
S 93.100.152.34:18909 0 B 0 B/s 0 B/s
S 131.213.31.241:21351 0 B 0 B/s 0 B/s
S 183.179.166.199:12702 0 B 0 B/s 0 B/s
S 118.158.165.27:37252 0 B 0 B/s 0 B/s
S 106.166.8.96:48056 0 B 0 B/s 0 B/s

@Bdoom

This comment has been minimized.

Copy link
Author

@Bdoom Bdoom commented Jul 7, 2019

Is there a reason why we cannot give a torrent url and just simply play a video? What are the requirements that a .torrent file must have for it to play in a browser?

@Bdoom Bdoom changed the title broken in plain html/ruby on rails What are the requirements for a torrent file to play in a browser? :) Jul 7, 2019
@adamwoo2444

This comment has been minimized.

Copy link

@adamwoo2444 adamwoo2444 commented Aug 5, 2019

+1

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 5, 2019

From the WebTorrent FAQ:

Why does browser downloading not work? I see no peers!

It does work! But you can't just use any random magnet uri or .torrent file. The torrent must be seeded by a WebRTC-capable client, i.e. WebTorrent Desktop, Vuze, webtorrent-hybrid, Playback, instant.io, or βTorrent.

In the browser, WebTorrent can only download torrents that are explicitly seeded to web peers via a WebRTC-capable client. Desktop torrent clients need to support WebRTC to connect to web browsers.

@feross feross closed this Aug 5, 2019
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 5, 2019

Also, see #1672 for a further explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.