AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://airensoft.com/ome.html
GNU Affero General Public License v3.0
2.57k stars 1.06k forks source link

http://<OME_HOST>:<API_PORT>/v1/stats/current/vhosts/{vhost_name} "totalConnections" seems incorrect #1016

Closed Pernifloss closed 1 year ago

Pernifloss commented 1 year ago

http://:/v1/stats/current/vhosts/{vhost_name} "totalConnections" return between 3 and 5 when I only have 1 viewer connected.

I start OvenMediaEngine with docker on my Windows 10 I have the default origin_conf/Server.xml config i enabled RTEST API

Here is an extract of the only part of the Server.xml I changed :

...
    <Managers>
        <API>
            <AccessToken>your_access_token</AccessToken>
        </API>
    </Managers>
    <!-- Settings for the ports to bind -->
    <Bind>
        <!-- Enable this configuration if you want to use API Server -->

        <Managers>
            <API>
                <Port>${env:OME_API_PORT:8081}</Port>
                <WorkerCount>1</WorkerCount>
            </API>
        </Managers>
...

and I run it with docker run -p 1935:1935 -p 3333:3333 -p 8081:8081 airensoft/ovenmediaengine:0.15.0

I then stream with OBS

And I display the stream using OvenMediaPlayer:

const player = OvenPlayer.create('player_id', {
        sources: [{
            label: 'stream',
            // Set the type to 'hls'
            "type": "hls",
            "file": "http://127.0.0.1:3333/app/stream/llhls.m3u8"
        }
        ]
    });

And my issue : REST API : http://:/v1/stats/current/vhosts/{vhost_name} return: When I'm streaming, and I have 0 viewer :

{
    "message": "OK",
    "response": {
      ...
        "maxTotalConnections": 0,
        "totalBytesIn": 923953,
        "totalBytesOut": 0,
        "totalConnections": 0
    },
    "statusCode": 200
}

When I start reading the stream with 1 player:


{
    "message": "OK",
    "response": {
        ...
        "maxTotalConnections": 4,
        "totalBytesIn": 30765965,
        "totalBytesOut": 1447007,
        "totalConnections": 4
    },
    "statusCode": 200
}

I have the same result with http://:/v1/stats/current/vhosts/{vhost_name}/apps/{app_name}/streams/{stream}

Is there something I don't understand? Why do I have 4 total connections when I only have 1 viewer?

getroot commented 1 year ago

Try setting <LLHLS><OriginMode>true</OriginMode> to false.

In OriginMode, it is assumed that edge servers connect to this origin server, and viewers connect to edge, so the totalConnections statistic is the actual number of tcp connections, not the number of viewers.

Pernifloss commented 1 year ago

Oh ! It seems to work perfectly now with <LLHLS><OriginMode>false</OriginMode> Thank you very much !