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.82k stars 5.4k forks source link

The source stream fails to be pulled via HTTP-FLV during the `http_hooks_on_publish` period, and subsequent stream pulls will continue to fail. #4182

Open retamia opened 2 months ago

retamia commented 2 months ago

Describe the bug

This occurs probabilistically. The source stream fails to be pulled via HTTP-FLV during the http_hooks_on_publish period, and subsequent stream pulls will continue to fail.

Version release6.0

To Reproduce Steps to reproduce the behavior:

  1. Add the code srs_usleep(2000 * SRS_UTIME_MILLISECONDS); to srs_error_t SrsRtmpConn::http_hooks_on_publish() to simulate a delay.
  2. Start streaming with OBS to rtmp://127.0.0.1:1935/live/test, then immediately run the following command in the terminal: ffprobe -rw_timeout 10000000 -i http://127.0.0.1:8080/live/test.flv.
  3. ffprobe will hang until it times out, and any subsequent executions of ffprobe will also time out, with all stream pulls failing.

Expected behavior pull normally

retamia commented 2 months ago

After reviewing the code, it seems that SrsLiveSourceManager::notify invokes SrsLiveSource::stream_is_dead to determine whether to remove an item from the map. When the on_publish callback has not yet returned, the can_publish_ state is true and stream_die_at_ is 0, which causes stream_is_dead() to return true, leading to the removal of the item from the map.

TRANS_BY_GPT4

retamia commented 2 months ago

@winlinvip

It's because this section of code was removed: #4097. After I restored this section, everything worked fine.