简体   繁体   中英

hls with basic authentication and SSL has little gaps

I try to get HLS working from lighttpd configured with basic authentication and SSL.

m3u8 file is like

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXTINF:6.012811,
taudio0.ts
#EXTINF:5.991067,
taudio1.ts
#EXTINF:6.013222,
taudio2.ts
#EXTINF:5.991222,
taudio3.ts
#EXTINF:6.014333,
taudio4.ts
#EXTINF:5.990922,
taudio5.ts
#EXTINF:6.001844,
taudio6.ts
#EXTINF:5.990444,
...
...
#EXTINF:2.740222,
taudio100.ts
#EXT-X-ENDLIST

I play the stream using this URL:

https://user:pwd@host.name.com:2222/taudio.m3u8

When I play it on my local.network/ wifi there is no gap due to.network speed, but when I'm not at home and I am on mobile data there are little gaps which is annoying.

I discovered this is due to the fact that the client app first try to get the *.ts file without authentication, then with authentication.
Lighttpd logs show:

192.168.1.1 host.name.com:2222 - [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio.m3u8 HTTP/1.1" 401 347 "-" "Lavf/59.29.100"
192.168.1.1 host.name.com:2222 user [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio.m3u8 HTTP/1.1" 206 3136 "-" "Lavf/59.29.100"
192.168.1.1 host.name.com:2222 - [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio0.ts HTTP/1.1" 401 347 "-" "Lavf/59.29.100"
192.168.1.1 host.name.com:2222 user [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio0.ts HTTP/1.1" 206 53768 "-" "Lavf/59.29.100"
192.168.1.1 host.name.com:2222 - [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio1.ts HTTP/1.1" 401 347 "-" "Lavf/59.29.100"
192.168.1.1 host.name.com:2222 user [19/Jul/2022:22:14:24 +0300] "GET /ta/taudio1.ts 

user is the username I use for basic authentication

I see the same behavior (try to get the file without auth then with auth) using:
Android: BSPlayer, MXPlayer, Poweramp
Linux: ffplay, mpv

If I remove basic authentication, the play goes smoothly.

Are all these players using the same library which has this strange behavior?
Or is there any header missing in my hls playlist taudio.m3u8.
Or anything else?
I'm stuck on this...

that behavior was caused by low max-keep-alive-idle in lighttpd configuration: the client request for a.ts file then connection was closed. For the next.ts file he open a new connection. Changed

max-keep-alive-idle=40

in lighttpd.conf
and now the log show:

192.168.1.1 host.name.ro:2222 - [20/Jul/2022:07:51:24 +0300] "GET /ta/taudio.m3u8 HTTP/1.1" 401 347 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:24 +0300] "GET /ta/taudio.m3u8 HTTP/1.1" 200 3136 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 - [20/Jul/2022:07:51:25 +0300] "GET /ta/taudio0.ts HTTP/1.1" 401 347 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:25 +0300] "GET /ta/taudio0.ts HTTP/1.1" 200 53768 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 - [20/Jul/2022:07:51:25 +0300] "GET /ta/taudio1.ts HTTP/1.1" 401 347 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:25 +0300] "GET /ta/taudio1.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:31 +0300] "GET /ta/taudio2.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:37 +0300] "GET /ta/taudio3.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:43 +0300] "GET /ta/taudio4.ts HTTP/1.1" 200 52828 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:49 +0300] "GET /ta/taudio5.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:51:55 +0300] "GET /ta/taudio6.ts HTTP/1.1" 200 53016 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:52:01 +0300] "GET /ta/taudio7.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:52:07 +0300] "GET /ta/taudio8.ts HTTP/1.1" 200 52640 "-" "Poweramp"
192.168.1.1 host.name.ro:2222 laptop [20/Jul/2022:07:52:13 +0300] "GET /ta/taudio9.ts HTTP/1.1" 200 53016 "-" "Poweramp"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM