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

Cookies are not sent when requesting a TS #6408

Closed
5 tasks done
xdz1 opened this issue May 11, 2024 · 1 comment
Closed
5 tasks done

Cookies are not sent when requesting a TS #6408

xdz1 opened this issue May 11, 2024 · 1 comment
Labels
Browser issue If there is an underlying issue with the browser that hls.js is running on, this tag should be used. Third-party issue

Comments

@xdz1
Copy link

xdz1 commented May 11, 2024

What version of Hls.js are you using?

最新版

What browser (including version) are you using?

Chrome 123.0.6312.106

What OS (including version) are you using?

Windows 11

Test stream

No response

Configuration

// 创建视频元素
        var video = document.getElementById('video');
        // 创建 hls.js 实例
        if (Hls.isSupported()) {

          var hls = new Hls({
            xhrSetup: function(xhr, url) {
              xhr.withCredentials = true; // do send cookies
            
            }
          });

          hls.loadSource('http://59.249.222.123:19003/rtp/caeacb1a2eff39d0b0a8a1c88ecc8f05/hls.m3u8');
          hls.attachMedia(video);
          hls.on(Hls.Events.MANIFEST_PARSED, function() {
            video.play();
          });

        }

Additional player setup steps

Checklist

Steps to reproduce

<title>Play M3U8 with hls.js</title> <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
    // 创建视频元素
    var video = document.getElementById('video');
    // 创建 hls.js 实例
    if (Hls.isSupported()) {

      var hls = new Hls({
        xhrSetup: function(xhr, url) {
          xhr.withCredentials = true; // do send cookies
        }
      });

      hls.loadSource('http://59.43.12.123:19003/rtp/4d7bf19ac73bf74286c48e1a746a9502/hls.m3u8');
      hls.attachMedia(video);
      hls.on(Hls.Events.MANIFEST_PARSED, function() {
        video.play();
      });

    }
</script>

Expected behaviour

No cookie is sent when requesting a TS

What actually happened?

http://59.249.222.123:19003/rtp/caeacb1a2eff39d0b0a8a1c88ecc8f05/hls.m3u8
Response header:
HTTP/1.1 200 OK
Content-Length: 215
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:63343
Connection: keep-alive
Content-Type: application/vnd.apple.mpegurl; charset=utf-8
Date: Sat, May 11 2024 08:52:49 GMT
Keep-Alive: timeout=4
Proxy-Connection: keep-alive
Server: ZLMediaKit(git hash:2ccb79a,branch:master,build time:Nov 29 2023 09:50:24)
Set-Cookie: ZL_COOKIE=f7c35614d1d432b7bff31653cf0a0d9a;expires=Sat, May 11 2024 08:53:49 GMT;path=/rtp/caeacb1a2eff39d0b0a8a1c88ecc8f05/
TS address:
http://59.249.222.123:19003/rtp/caeacb1a2eff39d0b0a8a1c88ecc8f05/2024-05-11/16/52-42_4.ts
n)

Console output

Request TS401 error

Chrome media internals output

@xdz1 xdz1 added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels May 11, 2024
@robwalch robwalch added Browser issue If there is an underlying issue with the browser that hls.js is running on, this tag should be used. and removed Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels May 11, 2024
@robwalch
Copy link
Collaborator

If a browser won't carry data over cookies (cookies can be disabled) then maybe you should send the required info via url parameter. This is not a bug with HLS.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser issue If there is an underlying issue with the browser that hls.js is running on, this tag should be used. Third-party issue
Projects
None yet
Development

No branches or pull requests

2 participants