ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.69k stars 5.38k forks source link

After using WEBRTC for streaming, the client counter cannot increase. #2497

Closed CNWenwuGong closed 3 years ago

CNWenwuGong commented 3 years ago

Description'

Please ensure that the markdown structure is maintained.

When I use WEBRTC to pull video streams, the number of clients connected to this stream in the query API is always 1.

  1. SRS version: 4.0
  2. The log of SRS is as follows:
    xxxxxxxxxxxx
  3. The configuration of SRS is as follows: daemon on; srs_log_tank console; srs_log_file ./objs/srs.log;

http_server { enabled on; listen 8080; dir ./objs/nginx/html; }

http_api { enabled on; listen 1985; } stats { network 0; disk sda sdb xvda xvdb; } rtc_server { enabled on;

Listen at udp://8000

listen 8000;
#
# The $CANDIDATE means fetch from env, if not configed, use * as default.
#
# The * means retrieving server IP automatically, from all network interfaces,
# @see https://github.com/ossrs/srs/wiki/v4_CN_RTCWiki#config-candidate
candidate 172.16.31.10;

}

vhost defaultVhost { rtc { enabled on; }

http_remux {

 #   enabled     on;
 #   mount       [vhost]/[app]/[stream].flv;
#}
http_hooks {
enabled         on;
    on_stop    http://172.16.31.96:9040/webapi/video/stopVideo;
}

Minimum delay open, which is enabled by default. When this option is enabled, MR is disabled by default.

min_latency     on;

Merged-Read, for the RTMP protocol, in order to improve performance, SRS uses merged-read for upstream reads, which means SRS reads N milliseconds of data at a time during read and write operations.

mr {
    enabled     off;

The default value is 350ms, with a range of [300-2000].

    #latency     350;
}

Merged-Write, SRS always uses Merged-Write, which means sending packets to the client once every N milliseconds. This algorithm can improve the efficiency of RTMP downstream by about 5 times, with a range of [350-1800].

mw_latency      100;
#enabled         on;
#https://github.com/simple-rtmp-server/srs/wiki/v2_CN_LowLatency#gop-cache
gop_cache       off;

Configure the length of the live queue. The server will store data in the live queue, and if it exceeds this length, it will be cleared until the last I-frame.

#https://github.com/simple-rtmp-server/srs/wiki/v2_CN_LowLatency#%E7%B4%AF%E7%A7%AF%E5%BB%B6%E8%BF%9F
queue_length    10;

HTTP-FLV configuration

http_remux {
    enabled     on;
    mount [vhost]/[app]/[stream].flv;
    hstrs   on;
}

tcp_nodelay     on
min_latency     on;

play {
    gop_cache       off;
    queue_length    10;
    mw_latency      100;
}

publish {
    mr off;
}

}

Replay

How to replay bug?

Steps to reproduce the bug

Steps to replay the bug:

  1. Use FFmpeg to stream to SRS.
  2. Play the stream on the SRS player page.
  3. Check in the SRS console or use the API to query the number of connections.

Request for urgent resolution, seeking help from experts.

TRANS_BY_GPT3

duiniuluantanqin commented 3 years ago

Try using the latest version of dev, this commit should have already resolved it. https://github.com/ossrs/srs/commit/86c67f7d9522ab592c6f99c3f5f88e934a649cd1

TRANS_BY_GPT3

LUOQING1994 commented 3 years ago

Try using the latest version of dev, this commit should have already resolved it. 86c67f7

Hello! I have used the version you mentioned, and the client count is working fine now, but there are still some issues:

  1. When stopping the stream, it takes more than 10 seconds for the client count to update.
  2. The http_hooks callback function is still not being called.
  3. The callback function is also not being called when streaming in flv format.

TRANS_BY_GPT3

duiniuluantanqin commented 3 years ago
  1. Have you confirmed that it has stopped? Use the Chrome browser and enter [chrome://webrtc-internals] to check if the status is already closed. Alternatively, try refreshing the browser.

2.3. The http_hook has not been done yet, let's discuss it next week.

TRANS_BY_GPT3

LUOQING1994 commented 3 years ago
  1. Have you confirmed that it has stopped? Use the Chrome browser, enter [chrome://webrtc-internals], and see if the status is already closed? Or try refreshing the browser?

2.3. The http_hook has not been done yet, let's discuss it next week.

I confirm that it has been closed, below are the screenshots: QQ截图20210804135938 This is a screenshot after stopping the stream: QQ截图20210804140002

TRANS_BY_GPT3

duiniuluantanqin commented 3 years ago

image

Check if there is a close in the Event.

TRANS_BY_GPT3

duiniuluantanqin commented 3 years ago

If there is no reply for a long time, let's assume it has been resolved. If not, you can reopen it.

TRANS_BY_GPT3