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

APPLICATION: When using http-flv playback, the traffic statistics are incorrect when calling the srs http api. However, the client connection count is accurate. #863

Closed
xialixin opened this issue Apr 28, 2017 · 5 comments
Assignees
Labels
API HTTP-API, HTTP-Callback, etc. Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@xialixin
Copy link
Contributor

xialixin commented Apr 28, 2017

When using http-flv for playback, the traffic statistics are incorrect. The parameters send_bytes and kbps.send_30s do not increase even after a certain number, but the client connection is correct. I have checked the SRS code and found that the statistics code is present in the http-flv related code.

int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{   ...
    // update the statistic when source disconveried.
    SrsStatistic* stat = SrsStatistic::instance();
    if ((ret = stat->on_client(_srs_context->get_id(), req, NULL, SrsRtmpConnPlay)) != ERROR_SUCCESS) {
        srs_error("stat client failed. ret=%d", ret);
        return ret;
    }
   ...
}

Continuing to track the code, the relevant traffic statistics code in SrsHttpConn is as follows:

void SrsHttpConn::resample()
{
    // TODO: FIXME: implements it
}

int64_t SrsHttpConn::get_send_bytes_delta()
{
    // TODO: FIXME: implements it
    return 0;
}

int64_t SrsHttpConn::get_recv_bytes_delta()
{
    // TODO: FIXME: implements it
    return 0;
}

void SrsHttpConn::cleanup()
{
    // TODO: FIXME: implements it
}

SrsHttpConn and SrsRtmpConn are both derived from the base class SrsConnection. In the SrsConnection class, the SrsKbps is called. To verify if it is related to the above code, simply modify the above code as follows, calling the relevant methods in the base class SrsConnection.

void SrsHttpConn::resample()
{
    SrsConnection::resample()
}

int64_t SrsHttpConn::get_send_bytes_delta()
{
    return SrsConnection::get_send_bytes_delta()
}

int64_t SrsHttpConn::get_recv_bytes_delta()
{
    return SrsConnection::get_recv_bytes_delta();
}
void SrsHttpConn::cleanup()
{
     SrsConnection::cleanup()
}

After recompiling, start SRS and then use the API to view the relevant parameters. The parameters send_bytes and kbps.send_30s keep increasing.
The above is the issue discovered during the testing process and is presented here for everyone's reference.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title http-flv流量统计问题:当使用http-flv播放时,调用srs http api查看流量统计不对,客户端连接数是对的 APPLICATION: 当使用http-flv播放时,调用srs http api查看流量统计不对,客户端连接数是对的 Apr 30, 2017
@winlinvip
Copy link
Member

winlinvip commented Apr 30, 2017

I will find time to take a look at why it was necessary to rewrite the base class for bandwidth statistics at that time.

TRANS_BY_GPT3

@winlinvip winlinvip added the Bug It might be a bug. label Apr 30, 2017
@winlinvip winlinvip added this to the srs 2.0 release milestone Apr 30, 2017
@superxrb
Copy link

superxrb commented Sep 25, 2017

The number of client connections has shown an incorrect situation. The steps are as follows:

  1. Play a non-existent stream using VLC, for example, http://192.168.177.181:8080/live/952700000A5S348E_0_ext.flv. At this time, the statistics at http://192.168.177.181:1985/api/v1/streams/ are correct, with "clients" being 1.

  2. Forcefully close VLC and check the statistics again. The statistics remain unchanged, with "clients" still being 1.

  3. Repeat the above two steps using the RTMP streaming method. It is found that in the second step, the statistics are correct, with "clients" being 0.

TRANS_BY_GPT3

@RocFang
Copy link
Contributor

RocFang commented Nov 16, 2017

@xialixin
Hello, how did you handle this issue later on? If your solution works, please create a pull request for winlin. :)

TRANS_BY_GPT3

@winlinvip
Copy link
Member

See #1657

@winlinvip
Copy link
Member

Fixed.

@winlinvip winlinvip added the API HTTP-API, HTTP-Callback, etc. label Aug 23, 2021
@winlinvip winlinvip changed the title APPLICATION: 当使用http-flv播放时,调用srs http api查看流量统计不对,客户端连接数是对的 APPLICATION: When using http-flv playback, the traffic statistics are incorrect when calling the srs http api. However, the client connection count is accurate. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API HTTP-API, HTTP-Callback, etc. Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

5 participants