ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.29k stars 636 forks source link

Negative HLS viewer count #6761

Open SebastienGautier opened 1 week ago

SebastienGautier commented 1 week ago

Short description

We have some streams that have a negative HLS viewer count

Environment

Steps to reproduce

image

Expected behavior

HLS viewer count should never be negative

Actual behavior

HLS viewer count is negative for some streams

We had writeStatsToDatastore set to false for some time if that could be related

Logs

Nothing that looks related

Ask your questions on Ant Media Github Discussions

burak-58 commented 5 days ago

I am putting this to the next sprint plan.

lastpeony commented 1 day ago

Hello @SebastienGautier,

I believe this issue occurred because the writeStatsToDatastore setting was disabled at some point, preventing the database from being updated. Here's how it works: the system calculates the viewer difference(can be positive or negative) and adds it to the current viewer count in the database. User sessions which are not updated for 20 seconds are considered dead and its -1 for hls viewer count. If you can provide more details about your use case and how this issue occurred, it will help me better understand the root cause.

In the meantime, we will implement a code change to ensure that the viewer count never falls below 0, as negative value is meaningless.