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

SOURCE: The SRS server crashed after stopping the stream. #671

Closed
MaxLoveThree opened this issue Oct 18, 2016 · 5 comments
Closed

SOURCE: The SRS server crashed after stopping the stream. #671

MaxLoveThree opened this issue Oct 18, 2016 · 5 comments
Assignees
Labels
Bug It might be a bug. Duplicated Duplicated bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@MaxLoveThree
Copy link

MaxLoveThree commented Oct 18, 2016

SRS version:
[root@localhost trunk]# ./objs/srs -v
2.0.219
Environment:
IP address: 172.16.198.129
Two SRS server programs, one is publish_edge, the other is origin
Configuration file for publish_edge:

[root@localhost trunk]# cat conf/publish_edge.conf 
# the config for srs to delivery RTMP
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleRTMP
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
pid                 ./objs/publish_edge.pid;
srs_log_file        ./objs/publish_edge.log;
chunk_size          4096;
http_api{
        enabled         on;
        listen          8088;
}
vhost **defaultVhost** {
        mode            remote;
        origin          127.0.0.1:19350;

security {
        enabled         on;
        allow           play        all;
        allow           publish     all;
}

http_hooks {
        enabled         off;
        on_publish      http://localhost:8080/live-monitor/room/checkStream.do;
}

gop_cache       off;
queue_length    5;
min_latency     on;
mw_latency      100;
tcp_nodelay     on;

}

Configuration file for origin:

[root@localhost trunk]# cat conf/origin.conf 
# the config for srs origin-edge cluster
# @see https://github.com/ossrs/srs/wiki/v1_CN_Edge
# @see full.conf for detail config.

listen              19350;
max_connections     1000;
pid                 objs/origin.pid;
srs_log_file        ./objs/origin.log;

http_api{
        enabled         on;
        listen          8090;
}

vhost **defaultVhost** {
}

Startup command:

./objs/srs -c ./conf/origin.conf
./objs/srs -c ./conf/publish_edge.conf

Specific operations:

Step 1: Use OBS to push the stream to the publish_edge server, rtmp://172.16.198.129:1935/my_test/client, and the push is successful.
Step 2: Use srs_player to pull the stream from the publish_edge server, rtmp://172.16.198.129:1935/my_test/client, and the pull is successful.
Step 3: After pulling the stream for 10 seconds, close srs_player to stop pulling the stream.
Step 4: When srs_player stops pulling the stream for 30 seconds, the publish_edge program crashes.

Crash core file stack trace:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000493c15 in SrsRtmpConn::process_publish_message (this=0x2e3c000, source=0x2dce1c0, msg=0x2ddee80, vhost_is_edge=true) at src/app/srs_app_rtmp_conn.cpp:1029
#2  0x0000000000493b41 in SrsRtmpConn::handle_publish_message (this=0x2e3c000, source=0x2dce1c0, msg=0x2ddee80, is_fmle=true, vhost_is_edge=true) at src/app/srs_app_rtmp_conn.cpp:1015
#3  0x000000000052e2a7 in SrsPublishRecvThread::handle (this=0x7f48520d8890, msg=0x2ddee80) at src/app/srs_app_recv_thread.cpp:386
#4  0x000000000052cd70 in SrsRecvThread::cycle (this=0x7f48520d8898) at src/app/srs_app_recv_thread.cpp:100
#5  0x00000000004c6b03 in SrsReusableThread2::cycle (this=0x2dc6e20) at src/app/srs_app_thread.cpp:540
#6  0x00000000004c5857 in internal::SrsThread::thread_cycle (this=0x2ddec80) at src/app/srs_app_thread.cpp:207
#7  0x00000000004c5a70 in internal::SrsThread::thread_fun (arg=0x2ddec80) at src/app/srs_app_thread.cpp:245
#8  0x0000000000557672 in _st_thread_main () at sched.c:327
#9  0x0000000000557e0c in st_thread_create (start=0x2, arg=0x2dc702c, joinable=32584, stk_size=1376618080) at sched.c:591
#10 0x00007f48520d8660 in ?? ()
#11 0x0000000000000006 in ?? () at src/base/logging.h:201
#12 0x00007f48520b4e90 in ?? ()
#13 0x00000003520d86b0 in ?? ()
#14 0x00000006ffffffff in ?? ()
#15 0x00007f48520d86b0 in ?? ()
#16 0x0000000000000000 in ?? ()

(gdb) 

TRANS_BY_GPT3

@MaxLoveThree
Copy link
Author

MaxLoveThree commented Oct 18, 2016

Hello, I have already identified the cause of the problem. After the streaming client stops pulling the stream for 30 seconds, the program will erase the "source" resource in the pool without checking whether the "publish_edge" of that source is still pushing the stream. I have made modifications to the SrsSource::expired interface in the srs_app_source.cpp file, and the modified version is as follows.
bool SrsSource::expired()
{
// unknown state?
if (die_at == -1){
return false;
}

// still publish?
// Added a check here to determine if "publish_edge" is still pushing the stream.
if ((!_can_publish) || (!publish_edge->can_publish())){    
    return false;
}


// has any consumers?
if (!consumers.empty()){
    return false;
}


int64_t now = srs_get_system_time_ms();
if (now > die_at + SRS_SOURCE_CLEANUP) {
    return true;
}


return false;

}

TRANS_BY_GPT3

@rooney0126
Copy link

rooney0126 commented Oct 20, 2016

There is indeed such a problem with srs2.0, it seems that adding a judgment on whether publish_edge is currently streaming can solve it.

TRANS_BY_GPT3

@winlinvip winlinvip added this to the srs 2.0 release milestone Oct 24, 2016
@winlinvip
Copy link
Member

winlinvip commented Oct 24, 2016

We will take a look. The logic has become more complex after adding Source cleaning.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Jan 6, 2017

SRS2 has removed the Source cleaning, resulting in higher memory usage, but it will not crash because of this.
To clean the Source and reduce memory without crashing, it is planned to be resolved in SRS3.

TRANS_BY_GPT3

@winlinvip winlinvip modified the milestones: srs 3.0 release, srs 2.0 release Jan 6, 2017
@winlinvip winlinvip changed the title srs服务器停止拉流后崩溃 KERNEL: srs服务器停止拉流后崩溃 Mar 26, 2017
@winlinvip winlinvip changed the title KERNEL: srs服务器停止拉流后崩溃 SOURCE: srs服务器停止拉流后崩溃 Mar 26, 2017
@winlinvip
Copy link
Member

winlinvip commented Jan 26, 2020

Up to #1579, plan to use hot upgrade to solve the Source cleaning issue.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Sep 23, 2021
@winlinvip winlinvip added Bug It might be a bug. Duplicated Duplicated bug. labels Sep 23, 2021
@winlinvip winlinvip changed the title SOURCE: srs服务器停止拉流后崩溃 SOURCE: The SRS server crashed after stopping the stream. 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
Bug It might be a bug. Duplicated Duplicated bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

3 participants