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

SrsLiveSource not release when forward hook failed #4246

Open
chukeer opened this issue Nov 29, 2024 · 0 comments
Open

SrsLiveSource not release when forward hook failed #4246

chukeer opened this issue Nov 29, 2024 · 0 comments
Labels
TransByAI Translated by AI/GPT.

Comments

@chukeer
Copy link

chukeer commented Nov 29, 2024

After the forward HTTP hook callback fails, the SrsLiveSource is not released, resulting in an error reporting "stream busy" upon the next stream push.

Version of the code.

1bd65f338 (2024-09-01 17:02:21 +0800) - (srs/6.0release) Refine release action. <winlin>

Example of a configuration file.

vhost __defaultVhost__ {
    forward {
        enabled on;
        backend http://127.0.0.1:22/forward;
    }

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

Stream method: ffmpeg -re -stream_loop -1 -i record-time.mp4 -c copy -f flv rtmp://10.8.69.50:1935/live/166zmh

The callback at http://127.0.0.1:22/forward will return a failure. The log from the first streaming attempt is as follows.

[2024-11-29 19:29:28.055][ERROR][897894][373ku012][11] serve error code=3009(HttpParseHeader)(HTTP parse header failed) : service cycle : rtmp: stream service : hub publish : create forwarders : create backend applied=1 : get forward ba
ckend failed, backend=http://127.0.0.1:22/forward : http: on_forward_backend failed, client_id=373ku012, url=http://127.0.0.1:22/forward, request={"action":"on_forward","server_id":"vid-oawkh82","service_id":"86a00o3t","client_id":"373k
u012","ip":"172.19.73.83","vhost":"__defaultVhost__","app":"live","tcUrl":"rtmp://10.8.69.50:1935/live","stream":"166zmh","param":"?dySecret=aafd3aaea75f9c632b05ae3c7e0e7675"}, response=, code=32708 : http: client post : http: parse res
ponse : parse message : parse 21B, nparsed=1, err=30/HPE_STRICT strict mode assertion failed
thread [897894][373ku012]: do_cycle() [./src/app/srs_app_rtmp_conn.cpp:265][errno=11]
thread [897894][373ku012]: service_cycle() [./src/app/srs_app_rtmp_conn.cpp:459][errno=11]
thread [897894][373ku012]: on_publish() [./src/app/srs_app_source.cpp:2594][errno=11]
thread [897894][373ku012]: on_publish() [./src/app/srs_app_source.cpp:1131][errno=11]
thread [897894][373ku012]: create_forwarders() [./src/app/srs_app_source.cpp:1474][errno=11]
thread [897894][373ku012]: create_backend_forwarders() [./src/app/srs_app_source.cpp:1528][errno=11]
thread [897894][373ku012]: on_forward_backend() [./src/app/srs_app_http_hooks.cpp:553][errno=11]
thread [897894][373ku012]: do_post() [./src/app/srs_app_http_hooks.cpp:614][errno=11]
thread [897894][373ku012]: post() [./src/protocol/srs_protocol_http_client.cpp:355][errno=11]
thread [897894][373ku012]: parse_message() [./src/protocol/srs_protocol_http_conn.cpp:103][errno=11]
thread [897894][373ku012]: parse_message_imp() [./src/protocol/srs_protocol_http_conn.cpp:136][errno=11](Resource temporarily unavailable)

Then, change the forward address to a normal address, attempt to re-stream, and an error occurs indicating "stream busy.

[2024-11-29 19:29:38.896][ERROR][897894][46r4840p][11] serve error code=1028(StreamBusy)(Stream already exists or busy) : service cycle : rtmp: stream service : rtmp: stream /live/166zmh is busy
thread [897894][46r4840p]: do_cycle() [./src/app/srs_app_rtmp_conn.cpp:265][errno=11]
thread [897894][46r4840p]: service_cycle() [./src/app/srs_app_rtmp_conn.cpp:459][errno=11]
thread [897894][46r4840p]: acquire_publish() [./src/app/srs_app_rtmp_conn.cpp:1080][errno=11](Resource temporarily unavailable)
[2024-11-29 19:29:38.896][INFO][897894][kwi40486] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0

In SrsRtmpConn::publishing, the call to acquire_publish fails. According to the comments, this error should be ignored, but there is no indication of a call to release_publish elsewhere.

    // TODO: FIXME: Should refine the state of publishing.
    srs_error_t acquire_err = acquire_publish(source);
    if ((err = acquire_err) == srs_success) {
        // use isolate thread to recv,
        // @see: https://github.com/ossrs/srs/issues/237
        SrsPublishRecvThread rtrd(rtmp, req, srs_netfd_fileno(stfd), 0, this, source, _srs_context->get_id());
        err = do_publishing(source, &rtrd);
        rtrd.stop();
    }
    
    // Release and callback when acquire publishing success, if not, we should ignore, because the source
    // is not published by this session.
    if (acquire_err == srs_success) {
        release_publish(source);
        http_hooks_on_unpublish();
    }

TRANS_BY_GPT4

@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants