API: over 20,000 zombie HLS clients
Closed this issue · 9 comments
SRS 6.0.169
curl -s "http://127.0.0.1:1985/api/v1/clients/?count=9999999" more 20 000 clients (real connections about 600)
Why are they frozen?
flv-play about 60 clients
hls-play more 20 000!!!
Example
[
{
"id": "848e0y93",
"vhost": "vid-446nd42",
"stream": "vid-064n65u",
"ip": "127.0.0.1",
"pageUrl": "",
"swfUrl": "",
"tcUrl": "http://127.0.0.1/hls",
"url": "/hls/myr",
"name": "crys.m3u8",
"type": "hls-play",
"publish": false,
"alive": 92256.96,
"send_bytes": 1780026,
"recv_bytes": 328,
"kbps": {
"recv_30s": 0,
"send_30s": 0
}
}
]
Reproduce
#!/usr/bin/env bash
bash
while true; do
ffmpeg -y -i "https://example.com/stream.m3u8" -map 0:v:0 -vframes 1 /tmp/output.png;
sleep 1;
done
After see
curl -s "http://127.0.0.1:1985/api/v1/clients/?count=10000"
Workarround
hls_ctx off;
hls_ts_ctx off;
How to reproduce.
TRANS_BY_GPT4
How to reproduce.
TRANS_BY_GPT4
updated
I've tested with the latest version and encountered no issues. Could you give it a try as well?
TRANS_BY_GPT4
Leave this script running for a little longer (for example, 15 minutes) and you will see that the number of clients is constantly increasing. In a few days I have accumulated 20,000 clients. Some bot was constantly requesting 3-4 stream from my server
I will proceed with further testing for a short period.
TRANS_BY_GPT4
I've been quite busy recently; it might take some time before I can get to it.
TRANS_BY_GPT4
This isn't a bug. After enabling hls_ctx/hls_ts_ctx, clients are not cleaned up in real-time; instead, they are cleared periodically by a timer. The cleanup interval is hls_window * 2, which is 120 seconds by default (60 * 2).
However, there were some minor issues in other areas, which have already been resolved.
In my case they did not clear. They accumulate and are not cleaned.
There was a minor bug before, causing some delay. Try the latest version, or stop streaming and wait for twice the duration of the hls_window to see if it clears up.