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

Videos doesn't work #1080

Closed
andreapaiola opened this issue Mar 18, 2017 · 8 comments
Closed

Videos doesn't work #1080

andreapaiola opened this issue Mar 18, 2017 · 8 comments

Comments

@andreapaiola
Copy link
Contributor

@andreapaiola andreapaiola commented Mar 18, 2017

What version of WebTorrent?
v0.98.14

What browser and version? (if using WebTorrent in the browser)
Chrome and Firefox, maybe all?

What did you expect to happen?
Images and videos load and render...

What actually happened?
Images work
Video doesn't work

Example:
https://andreapaiola.name/php-p2p-webtorrent-cdn/

Only a video
https://andreapaiola.name/php-p2p-webtorrent-cdn/video.php

The .torrent files are generated by php, but in a BitTorrent client like Transmission all works...

@andreapaiola

This comment has been minimized.

Copy link
Contributor Author

@andreapaiola andreapaiola commented Mar 19, 2017

Added audio test, it works.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 19, 2017

Your server is misbehaving. It claims to support Range requests but it's not handling them correctly.

Look at the network tab in Chrome, at the request for sintel.mp4. The request contains the header:

Range: bytes={start}-{end}

So, a valid server response is either:

  1. HTTP 200, indicating that the server did not understand the range request (and it will return the whole file)

  2. HTTP 206, indicating the server understood the range request (and it will return ONLY the requested range)

In case 2, the server will include the following headers:

Accept-Ranges: bytes
Content-Range: bytes {start}-{end}/{total}

The first indicates that it supports Range requests, and the second confirms the range that is being returned.

Your server is doing a mix of these things which is incorrect:

  1. Returning HTTP 200 and returning the full file
  2. Including the header Accept-Ranges: bytes indicates it supports Range requests, but it's missing Content-Range.

If you replace the web seed URL with https://webtorrent.io/torrents/sintel-1024-surround.mp4 you can see how a well-behaved server works.

@feross feross closed this Mar 19, 2017
@andreapaiola

This comment has been minimized.

Copy link
Contributor Author

@andreapaiola andreapaiola commented Mar 20, 2017

@andreapaiola

This comment has been minimized.

Copy link
Contributor Author

@andreapaiola andreapaiola commented Mar 20, 2017

@andreapaiola

This comment has been minimized.

Copy link
Contributor Author

@andreapaiola andreapaiola commented Mar 20, 2017

And it seems to me that it downloads the videos...

schermata 2017-03-20 alle 13 38 04

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 20, 2017

Content-Range isn't being set when the XHR request is made from the page. Look in the Network tab on your page: https://andreapaiola.name/php-p2p-webtorrent-cdn/video.php

These are the response headers:

HTTP/1.1 200 OK
Date: Mon, 20 Mar 2017 23:47:23 GMT
Server: Apache
Last-Modified: Sat, 18 Mar 2017 21:42:21 GMT
Accept-Ranges: bytes
Cache-Control: max-age=2592000
Expires: Wed, 19 Apr 2017 23:47:23 GMT
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
X-Powered-By: PleskLin
P3P: policyref="/w3c/p3p.xml", CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
X-Content-Type-Options: nosniff
Access-Control-Allow-Origin: *
Keep-Alive: timeout=15, max=9996
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: video/mp4

It's definitely odd that the correct headers are set when you visit the URL directly. I would look at the headers that are being sent with each request and see if there's a difference that's causing your server to misbehave.

@andreapaiola

This comment has been minimized.

Copy link
Contributor Author

@andreapaiola andreapaiola commented Mar 21, 2017

Yeah I made a simple XHR request and I can confirm that

https://andreapaiola.name/php-p2p-webtorrent-cdn/video-test.php

I disabled gzip compression for .mp4 files with

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary

in the .htaccess

and now it works

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 3, 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 3, 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
2 participants
You can’t perform that action at this time.