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.37k stars 5.34k forks source link

Edge: Still retry when no player on edge. After the client's FLV streaming is disconnected, the edge node continues to cyclically pull the stream from the master node. #3158

Open LastingZ opened 2 years ago

LastingZ commented 2 years ago

Description

Hello, we have deployed two master servers and two edge servers. We have configured rtmp and flv streaming on the edge servers. When a client disconnects after pulling a stream via rtmp, we can see that the edge server still has information about this stream in its streams. Then, when the stream is disconnected from the source, we can see that the edge server keeps requesting this stream from the master server in a continuous loop. The master server reports an error "server error 3090" and the edge server reports an error "origin disconnect retry 1007".

1. SRS Version

Version: 3.0.168

1. SRS Log

Log:

**Master's Log**
[2022-08-31 16:44:16.932][Trace][1458][1068255] client identified, type=Play, vhost=10.230.174.162, app=live/10000, stream=6ff9f1bb760149619b6377479362ce3a, param=?from=ztt, duration=-1ms
[2022-08-31 16:44:16.932][Trace][1458][1068255] connected stream, tcUrl=rtmp://10.230.174.162/live/10000, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live/10000, stream=6ff9f1bb760149619b6377479362ce3a, param=?from=ztt, args=(obj)
[2022-08-31 16:44:16.932][Trace][1458][1068255] source url=/live/10000/6ff9f1bb760149619b6377479362ce3a, ip=::ffff:10.230.174.125, cache=1, is_edge=0, source_id=0/1068242
[2022-08-31 16:44:16.934][Trace][1458][1068255] http: on_play ok, client_id=1068255, url=http://10.230.135.74:8001/srs/play, request={"action":"on_play","client_id":1068255,"ip":"::ffff:10.230.174.125","vhost":"__defaultVhost__","app":"live/10000","stream":"6ff9f1bb760149619b6377479362ce3a","param":"?from=ztt","pageUrl":""}, response=0
[2022-08-31 16:44:16.936][Trace][1458][1068255] http: on_stop ok, client_id=1068255, url=http://10.230.135.74:8001/srs/stop, request={"action":"on_stop","client_id":1068255,"ip":"::ffff:10.230.174.125","vhost":"__defaultVhost__","app":"live/10000","stream":"6ff9f1bb760149619b6377479362ce3a","param":"?from=ztt"}, response=0
[2022-08-31 16:44:16.936][Error][1458][1068255][0] serve error code=3090 : service cycle : rtmp: stream service : discover coworkers, url=http://10.230.174.163:1985/api/v1/clusters?vhost=__defaultVhost__&ip=10.230.174.162&app=live/10000&stream=6ff9f1bb760149619b6377479362ce3a&coworker=10.230.174.163:1985 : parse data {"code":0,"data":{"query":{"ip":"10.230.174.162","vhost":"__defaultVhost__","app":"live/10000","stream":"6ff9f1bb760149619b6377479362ce3a"},"origin":null}}
thread [1458][1068255]: do_cycle() [src/app/srs_app_rtmp_conn.cpp:210][errno=0]
thread [1458][1068255]: service_cycle() [src/app/srs_app_rtmp_conn.cpp:399][errno=0]
thread [1458][1068255]: playing() [src/app/srs_app_rtmp_conn.cpp:621][errno=11]
thread [1458][1068255]: discover_co_workers() [src/app/srs_app_http_hooks.cpp:453][errno=11]
[2022-08-31 16:44:19.990][Trace][1458][1068256] API server client, ip=10.230.174.163
[2022-08-31 16:44:19.990][Trace][1458][1068256] HTTP API POST http://10.230.174.162:1985/api/v1/clusters?vhost=__defaultVhost__&ip=10.230.174.163&app=live/10000&stream=6ff9f1bb760149619b6377479362ce3a&coworker=10.230.174.162:1985, content-length=0, chunked=0/0
[2022-08-31 16:44:19.991][Warn][1458][1068256][104] client disconnect peer. ret=1007
[2022-08-31 16:44:22.993][Trace][1458][1068257] RTMP client ip=::ffff:10.230.174.125, fd=11
[2022-08-31 16:44:23.000][Trace][1458][1068257] complex handshake success
[2022-08-31 16:44:23.000][Trace][1458][1068257] connect app, tcUrl=rtmp://10.230.174.162/live/10000, pageUrl=, swfUrl=, schema=rtmp, vhost=10.230.174.162, port=1935, app=live/10000, args=(obj)
[2022-08-31 16:44:23.000][Trace][1458][1068257] edge-srs ip=10.230.174.125, version=3.0.168, pid=24968, id=146
[2022-08-31 16:44:23.000][Trace][1458][1068257] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2022-08-31 16:44:23.000][Trace][1458][1068257] client identified, type=Play, vhost=10.230.174.162, app=live/10000, stream=6ff9f1bb760149619b6377479362ce3a, param=?from=ztt, duration=-1ms

[2022-08-31 16:44:23.000][Trace][1458][1068257] source url=/live/10000/6ff9f1bb760149619b6377479362ce3a, ip=::ffff:10.230.174.125, cache=1, is_edge=0, source_id=0/1068242

[2022-08-31 16:44:23.005][Error][1458][1068257][0] serve error code=3090 : service cycle : rtmp: stream service : discover coworkers, url=http://10.230.174.163:1985/api/v1/clusters?vhost=__defaultVhost__&ip=10.230.174.162&app=live/10000&stream=6ff9f1bb760149619b6377479362ce3a&coworker=10.230.174.163:1985 : parse data {"code":0,"data":{"query":{"ip":"10.230.174.162","vhost":"__defaultVhost__","app":"live/10000","stream":"6ff9f1bb760149619b6377479362ce3a"},"origin":null}}
thread [1458][1068257]: do_cycle() [src/app/srs_app_rtmp_conn.cpp:210][errno=0]
thread [1458][1068257]: service_cycle() [src/app/srs_app_rtmp_conn.cpp:399][errno=0]
thread [1458][1068257]: playing() [src/app/srs_app_rtmp_conn.cpp:621][errno=11]
thread [1458][1068257]: discover_co_workers() [src/app/srs_app_http_hooks.cpp:453][errno=11]

1. SRS Config (Configuration):

**Edge Configuration**
listen [::]:1935;
max_connections 1000;
pid ./objs/edge.pid;
srs_log_tank file;
srs_log_file ./objs/srs.log;
http_api {
    enabled on;
    listen 1985;
    raw_api {
        enabled on;
        allow_reload on;
        allow_query on;
        allow_update on;
    }
}
http_server {
    enabled on;
    listen 8081;
    dir ./objs/nginx/html/players;
}
stats {
    network 0;
    disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
    cluster {
        mode remote;
        origin 10.230.174.162:1935 10.230.174.163:1935;
    }
    http_remux {
        enabled on;
        fast_cache 10;
        mount [vhost]/[app]/[app]/[stream].aac;
    }
    http_hooks {
        enabled on;
        on_connect http://10.230.135.74:8001/srs/play;
        on_close http://10.230.135.74:8001/srs/play;
        on_publish http://10.230.135.74:8001/srs/publish;
        on_unpublish http://10.230.135.74:8001/srs/unpublish;
        on_play http://10.230.135.74:8001/srs/play;
        on_stop http://10.230.135.74:8001/srs/stop;
    }
}

Replay (重现)

Please describe how to replay the bug? (重现Bug的步骤)

  1. Start the master and edge servers, configure the edge server to use the flv and rtmp pull method.
  2. Push the rtmp stream to the master server, then use the pulling client to pull the rtmp stream from the edge server.
  3. Disconnect the pulling client and stop the pushing stream from the broadcaster, but the edge server still keeps requesting data from the master server.

Expect (Expected Behavior)

Please describe your expectation:

  1. When there are no clients pulling the stream, the edge server should stop requesting the stream from the master server in a loop.

TRANS_BY_GPT3

winlinvip commented 2 years ago

Is pulling the stream pulling FLV? Isn't what you configured .aac? Please confirm the reproduction path.

TRANS_BY_GPT3

LastingZ commented 2 years ago

Is the stream pulling FLV? Isn't it configured as .aac? Please confirm the reproduction path.

Hello, even if configured as aac and pulling rtmp, this situation can still occur~ However, as long as http_remux is turned off, this situation will not happen. We have also noticed that when there is no client pulling the stream from the edge, the stream can still be seen in the edge's streams.

TRANS_BY_GPT3

thanhdat9526 commented 12 months ago

Hi Winlinvip,

I also encountered this error when using it, have you checked and fixed the error? I need a solution to this problem immediately

Thanks.

winlinvip commented 11 months ago

The edge will stop retrieving from the source station when there's no client playing. This is the basic logic. If there's an issue with this, please provide a clear way to reproduce the problem.

TRANS_BY_GPT4