warren-bank / HLS-Proxy

Node.js server to proxy HLS video streams
http://webcast-reloaded.surge.sh/proxy.html
GNU General Public License v2.0
238 stars 68 forks source link

This page isn’t working HTTP ERROR 500 #22

Closed Nomanali3468 closed 1 year ago

Nomanali3468 commented 1 year ago

hi sir hope u are will be fine im getting this issue i cant figure out how to solve This page isn’t working 192.168.8.100 is currently unable to handle this request. HTTP ERROR 500

and on the second site i am getting when i opened in browser

EXTM3U

EXT-X-VERSION:3

EXT-X-MEDIA-SEQUENCE:770769428

EXT-X-TARGETDURATION:4

EXTINF:4.000, no desc

dad0-1313565080_MDL_ap-singapore_634E5F8E000072F08E6D-p0_tmpl360p_360p-1670677956020.ts?utc=1670677956020&pts=371141281800&txl=1670677958764

EXTINF:4.000, no desc

dad0-1313565080_MDL_ap-singapore_634E5F8E000072F08E6D-p0_tmpl360p_360p-1670677960020.ts?utc=1670677960020&pts=371141641800&txl=1670677962813

EXTINF:4.000, no desc

dad0-1313565080_MDL_ap-singapore_634E5F8E000072F08E6D-p0_tmpl360p_360p-1670677964020.ts?utc=1670677964020&pts=371142001800&txl=1670677966848

EXTINF:4.000, no desc

dad0-1313565080_MDL_ap-singapore_634E5F8E000072F08E6D-p0_tmpl360p_360p-1670677968020.ts?utc=1670677968020&pts=371142361800&txl=1670677970844

EXTINF:4.000, no desc

dad0-1313565080_MDL_ap-singapore_634E5F8E000072F08E6D-p0_tmpl360p_360p-1670677972020.ts?utc=1670677972020&pts=371142721800&txl=1670677974847

when i tried to play its play and stopped immediately

Can you please take a look on my issue

warren-bank commented 1 year ago

manifest URL?

I just did a fresh install and quick test (of CBS News).. and everything appears to be working perfectly. Have you used this proxy before? Are you familiar with how to use it? tldr;

Nomanali3468 commented 1 year ago

manifest URL?

I just did a fresh install and quick test (of CBS News).. and everything appears to be working perfectly. Have you used this proxy before? Are you familiar with how to use it? tldr;

url > https://video.gslb.startimestv.com/live_record_g/STAR_LIFE_1494_500_480x360_v1_FMP4/playlist.m3u8 yes sir i knows basic but not much familiar

warren-bank commented 1 year ago

proxied manifest

HTTP response code from origin server: 403 Forbidden

so your manifest is (in some way) protected.. by either: a Referer header, Cookie session, etc..

warren-bank commented 1 year ago

you can play around with curl.. and once you find the request necessary to get a 200 OK response.. then replicate it by the proxy.

Nomanali3468 commented 1 year ago

proxied manifest

HTTP response code from origin server: 403 Forbidden

so your manifest is (in some way) protected.. by either: a Referer header, Cookie session, etc..

yeah sir but i have added the request headers according to your docs and even i have tried the samething with streamlink and its playing without any issues

Nomanali3468 commented 1 year ago

you can play around with curl.. and once you find the request necessary to get a 200 OK response.. then replicate it by the proxy.

with curl i can get 200 response and i knows there is cookies which is necessary with the m3u8 when i need to play and i have done with cookies header but when i tried on proxy nothing works

warren-bank commented 1 year ago

without sharing your session cookie.. how are you configuring the proxy to use it? ..which option, what format, etc

warren-bank commented 1 year ago

the most basic way to do so is:

hlsd --header "Cookie: xxxx"
Nomanali3468 commented 1 year ago

without sharing your session cookie.. how are you configuring the proxy to use it? ..which option, what format, etc

here is my requested method npm start --host "192.168.8.100" --port "8080" --origin "https://webtv.startimestv.com" --referer "https://webtv.startimestv.com/" --headers "_ga=GA1.1.1845618781.1670246406; CloudFront-Key-Pair-Id=APKAIPKYIDIQPHMZ2WKA; _ga_4D3XLF682K=GS1.1.1670673103.6.0.1670673103.0.0.0; CloudFront-Signature=YFfPLQddyrsuwVFBQqZ6ZsKTRbVuuVLBLntxktOMhoEq0wCPJkW5GOs82TOYuwb4A1Qaqj5bVhIe-MgsCqtpk0nLxz8ez~1fR6wHBZcbRHJcI2qAdI8uGgyMZ7vmNIzMUgB-gleuJrJ0lAbNz~RX7UeSIc1hB0y62jsMXnEecw4Y6GFmwgJqhpK-SiLl~R7GsutLtdah2ZiTzoJoYsDIxSf~jKkqpytIADTHBMZ156veW5rtXoY5IS5UpmEApquWUkn8NEGDPgalE3sfjq-0xoje~hGl~YVC42juRUw3kI3N3~1IFuPlwRVIBoRR-VNPnTvIQwEPozP0Btq0nvAqsQ__; CloudFront-Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHA6Ly8qLnN0YXJ0aW1lc3R2LmNvbS9saXZlX3JlY29yKiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTY3MDY4MDM3OX19fV19 "--useragent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"

warren-bank commented 1 year ago

--headers isn't a valid cli option. --header takes a single inline value (ie: "name: value"). --req-headers takes a filepath to a JSON file.

Nomanali3468 commented 1 year ago

--headers takes a filepath to a JSON file

i think here im wrong ok sir let me try again and what we can do if the cookies will expire after 20 mintues

warren-bank commented 1 year ago

PS: after you've configured the proxy.. to test that your requests are sending the desired request headers.. you can proxy a request to httpbin.org/headers by requesting this link directly in your browser and directly inspect the headers

Nomanali3468 commented 1 year ago

PS: after you've configured the proxy.. to test that your requests are sending the desired request headers.. you can proxy a request to httpbin.org/headers by requesting this link directly in your browser and directly inspect the headers

ok sir

Nomanali3468 commented 1 year ago

PS: after you've configured the proxy.. to test that your requests are sending the desired request headers.. you can proxy a request to httpbin.org/headers by requesting this link directly in your browser and directly inspect the headers

im getting this sir { "headers": { "Accept-Encoding": "identity, gzip, deflate, br", "Host": "httpbin.org", "X-Amzn-Trace-Id": "Root=1-6394a885-6f0dafa87eae70763095e650" } }

Nomanali3468 commented 1 year ago

PS: after you've configured the proxy.. to test that your requests are sending the desired request headers.. you can proxy a request to httpbin.org/headers by requesting this link directly in your browser and directly inspect the headers

thanks for ur help sir finally i have done with cookies header but now im getting another issue which i have already described in my 1st post

Nomanali3468 commented 1 year ago

PS: after you've configured the proxy.. to test that your requests are sending the desired request headers.. you can proxy a request to httpbin.org/headers by requesting this link directly in your browser and directly inspect the headers

now i can see something like that and when i opened in browser but when i tried to play its played and stopped immidiatley

Nomanali3468 commented 1 year ago

EXTM3U

EXT-X-VERSION:7

EXT-X-TARGETDURATION:12

EXT-X-MEDIA-SEQUENCE:666654

EXT-X-MAP:URI="init_503970.mp4",STAR-INIT-DATA="eJytUr9Lw0AUfneppYLQDi10cKjipDjUX7i1qEN3sS4ixl5qSpOm5GKoTlndBFHEyUVw9y8QBScHdwfdHAQdOyj13bXSJKWlgo9w3/vx5e69+w4A0mXnoF7h1iIABcQls76QBYicmpblAoBhujqDgClvEoj8ukaCrHCch4FG8Ydrx1ar6G85VXmmMmB3mSN/PpesmayiopMxWXiu4qRYUw8ymNWZYf9WuLVf8zPXMWYFtcYMTXI+zEqtjJjgZmDTKdbOjzNbK/vaG9u3jUzHv+HOroG4xx3OfJxNFELtGYlCotsqzGucceEonudNIi2CmMynZHH7VawjmKGpWBSBUNmi43Bfixjzki9OYnwYvBfBKVndkGYH6EShnw2hE/UwrcviY3+d5uS6cS8hoJNbYZqfWcTY6upEGh2dkm5bJ38LQ2hFljtavYe0etY1N9tnTCAvOFIBnUI/Ro+lWy0xje6WVgnZQfdYpnOf8PXdbALElQzuks6TMdJqCYIiGIr4cqfnoxNYnF4hJFS5jMdGrs6K1ZOZuwsqMnKZS4iHE10jt/zpCA9J1FVeR4xAW9h/eDBQMF2tgZhxbIm/txC+CX+dhus/8ziLrA=="

EXTINF:12.0,

666654.m4s

EXTINF:12.0,

666655.m4s

EXTINF:12.0,

666656.m4s

EXTINF:12.0,

666657.m4s

EXTINF:12.0,

666658.m4s

EXTINF:12.0,

666659.m4s

EXTINF:12.0,

666660.m4s

EXTINF:12.0,

666661.m4s

EXTINF:12.0,

666662.m4s

EXTINF:12.0,

666663.m4s

warren-bank commented 1 year ago

well, it seems that the server is behaving as expected.. and video host-specific configuration is the issue.. which is an exercise for the user to get right.

also, of course, to play the proxied stream in a video player that supports its format. I'm not sure if Clappr supports "m4s" video segments.. but you could just test the stream in VLC (or similar).

good luck.

warren-bank commented 1 year ago

oh.. I just noticed an issue that would cause a problem for you.

A manifest that uses fragmented mp4 segments (as your does) needs to use: #EXT-X-MAP:.. and my recent rewrite (somehow) forgot to include support for this tag. I'll quickly push an update.. in the next few minutes; that might be the reason your video only played for a few seconds and then quit (..but not certain).

update:

test:

Nomanali3468 commented 1 year ago

oh.. I just noticed an issue that would cause a problem for you.

A manifest that uses fragmented mp4 segments (as your does) needs to use: #EXT-X-MAP:.. and my recent rewrite (somehow) forgot to include support for this tag. I'll quickly push an update.. in the next few minutes; that might be the reason your video only played for a few seconds and then quit (..but not certain).

update:

  • v3.1.1 is pushed to npm.. you'll need to reinstall.. but this new version is needed for your manifest; sorry about that.

test:

thanks u very much sir and god bless u for making things easier for us

warren-bank commented 1 year ago

did the new version have an effect on your ability to proxy the manifest that you've been testing? ..any change?

Nomanali3468 commented 1 year ago

did the new version have an effect on your ability to proxy the manifest that you've been testing? ..any change?

i just reinstalled still testing

Nomanali3468 commented 1 year ago

did the new version have an effect on your ability to proxy the manifest that you've been testing? ..any change?

i will update you when its work

Nomanali3468 commented 1 year ago

did the new version have an effect on your ability to proxy the manifest that you've been testing? ..any change?

Yes sir finally you did it Its working Now

warren-bank commented 1 year ago

glad to hear it..

that was completely my mistake. thank you for reporting your issue.. so we were able to track down my error.

Nomanali3468 commented 1 year ago

did the new version have an effect on your ability to proxy the manifest that you've been testing? ..any change?

glad to hear it..

that was completely my mistake. thank you for reporting your issue.. so we were able to track down my error.

yeah sir what about Cookies updating is there a way to do that with javascript

warren-bank commented 1 year ago

hmm.. that's another matter entirely.

if the server issues cookies that expire after a short period of time that the cookie has been inactive, then (off the top of my head) some options might include:

  1. write a script that loops.. waiting a specific period of time between iterations (ex: 10 minutes).. and within each iteration it makes an HTTP request to the keep the existing cookie alive
  2. if the server changes the value of its cookie during each iteration, then you'd need to run hls-proxy with a hook function that is able to get the current value of your cookie from a method of storage that can be shared by both the proxy and your script (ex: a database, or even just a text file)
    • ex: {"add_request_headers": (url, is_m3u8) => ({"Cookie": "xxx"})}
Nomanali3468 commented 1 year ago

hmm.. that's another matter entirely.

if the server issues cookies that expire after a short period of time that the cookie has been inactive, then (off the top of my head) some options might include:

  1. write a script that loops.. waiting a specific period of time between iterations (ex: 10 minutes).. and within each iteration it makes an HTTP request to the keep the existing cookie alive
  2. if the server changes the value of its cookie during each iteration, then you'd need to run hls-proxy with a hook function that is able to get the current value of your cookie from a method of storage that can be shared by both the proxy and your script (ex: a database, or even just a text file)

ok sir thnx idea i will try do something like that hope i can do that i will update you once i done that

warren-bank commented 1 year ago

no need for an update.. but good luck

and thanks again for the bug report.

warren-bank commented 1 year ago

I gave your question (about cookies) a little more thought.

The HTTP client library that the proxy uses does support using a cookie jar object, though the proxy itself doesn't utilize that feature.

I was thinking of adding a new hook method:

module.exports = {
  request_intervals: (add_request_interval) => {

    add_request_interval(
      0, // run timer once at startup to initialize cookies
      (request) => {
        request('https://example.com/login', {username: 'me', password: '12345'})
      }
    )

    add_request_interval(
      (1000 * 60 * 5), // run timer at 5 minute interval to refresh cookies
      (request) => {
        request('https://example.com/heart-beat')
      }
    )

  }
}

If the proxy is started without the hook request_intervals defined, then no change.

However, if it is defined, then:

warren-bank commented 1 year ago

update: v3.2.0 was just pushed to npm with the new hook that I described (above). I did a few quick tests, and it works well.

Nomanali3468 commented 1 year ago

update: v3.2.0 was just pushed to npm with the new hook that I described (above). I did a few quick tests, and it works well.

i will try thnx for adding this feature