ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-srs:3 kill HTTP-FLV client container will exit automatically

yangxiangzhi opened this issue · comments

docker-srs:3 kill client container will exit automatically

  1. SRS version: docker-srs:3
  2. SRS logs are as follows:
container-srs   | [2020-03-05 10:18:03.193][Trace][1][1086] HTTP API GET http://docker-srs:1985/api/v1/clients?start=0&count=10000, content-length=-1, chunk
ed=0/0
container-srs   | [2020-03-05 10:18:03.193][Trace][1][1086] client finished.
container-srs   | [2020-03-05 10:18:03.206][Trace][1][1087] API server client, ip=172.20.0.5
container-srs   | [2020-03-05 10:18:03.206][Trace][1][1087] HTTP API GET http://docker-srs:1985/api/v1/clients/?start=0&count=10000, content-length=-1, chun
ked=0/0
container-srs   | [2020-03-05 10:18:03.206][Trace][1][1087] client finished.
container-srs   | [2020-03-05 10:18:03.355][Trace][1][1088] API server client, ip=172.20.0.5
container-srs   | [2020-03-05 10:18:03.355][Trace][1][1088] HTTP API DELETE http://docker-srs:1985/api/v1/clients/1079, content-length=-1, chunked=0/0
container-srs exited with code 139

As you can see, I made a request to the built-in API of SRS to get the clients, and then killed one client. As a result, the container automatically exited. This is why I am hesitant to perform the kill action on the production server. This issue does not occur every time I kill a client. I have noticed that sometimes it happens, while other times the SRS container does not exit.

This is a very critical issue with the SRS API, which makes me hesitant to perform any actions on users who are watching live streams in a non-conventional way. It is important to resolve this issue promptly.

TRANS_BY_GPT3

Unable to reproduce the issue, please reproduce the issue first and describe the reproduction steps.

TRANS_BY_GPT3

Hello, today when I was testing, I discovered a pattern:

  1. If I kill the RTMP stream, the issue mentioned above will not reoccur.
  2. If I kill the FLV stream, during local testing, it happens every time and the container will exit.

Additionally, I also found that the interface http://127.0.0.1:1985/api/v1/clients still cannot monitor the HLS streaming clients.

TRANS_BY_GPT3

Great, I will try the kickoff of FLV, and if it can be reproduced, I will fix it quickly.

TRANS_BY_GPT3

Ok, thank you!

TRANS_BY_GPT3

Reproduced, it will cause SRS crash and exit.

Program received signal SIGSEGV, Segmentation fault.
0x000000000054496a in SrsGoApiClients::serve_http (this=0x266ee30, w=0x7fbd1b125bc0, r=0x26910b0)
    at src/app/srs_app_http_api.cpp:841
841	        client->conn->expire();
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64 libgcc-4.8.5-39.el7.x86_64 libstdc++-4.8.5-39.el7.x86_64
(gdb) bt
#0  0x000000000054496a in SrsGoApiClients::serve_http (this=0x266ee30, w=0x7fbd1b125bc0, r=0x26910b0)
    at src/app/srs_app_http_api.cpp:841
#1  0x00000000004940ce in SrsHttpServeMux::serve_http (this=0x264f560, w=0x7fbd1b125bc0, r=0x26910b0)
    at src/protocol/srs_http_stack.cpp:711
#2  0x0000000000494ea5 in SrsHttpCorsMux::serve_http (this=0x268e290, w=0x7fbd1b125bc0, r=0x26910b0)
    at src/protocol/srs_http_stack.cpp:859
#3  0x000000000054b460 in SrsHttpApi::process_request (this=0x268e030, w=0x7fbd1b125bc0, r=0x26910b0)
    at src/app/srs_app_http_api.cpp:1403
#4  0x000000000054b070 in SrsHttpApi::do_cycle (this=0x268e030) at src/app/srs_app_http_api.cpp:1368

TRANS_BY_GPT3

Due to the lack of a connection (conn=0x0) for the API client during HTTP-FLV playback, it results in a null pointer reference when attempting to kick HTTP-FLV.

Breakpoint 1, SrsStatistic::on_client (this=0x105cdc0, id=189, req=0x105e910, conn=0x0, type=SrsRtmpConnPlay)
    at src/app/srs_app_statistic.cpp:408
408	    srs_error_t err = srs_success;
(gdb) bt
#0  SrsStatistic::on_client (this=0x105cdc0, id=189, req=0x105e910, conn=0x0, type=SrsRtmpConnPlay)
    at src/app/srs_app_statistic.cpp:408
#1  0x00000000004ef0c7 in SrsLiveStream::do_serve_http (this=0x105e570, w=0x7f86c1ed8b90, r=0x107acf0)
    at src/app/srs_app_http_stream.cpp:598
#2  0x00000000004ee8fa in SrsLiveStream::serve_http (this=0x105e570, w=0x7f86c1ed8b90, r=0x107acf0)
    at src/app/srs_app_http_stream.cpp:544
#3  0x00000000004940ce in SrsHttpServeMux::serve_http (this=0x1031630, w=0x7f86c1ed8b90, r=0x107acf0)
    at src/protocol/srs_http_stack.cpp:711

TRANS_BY_GPT3

Already resolved:

[2020-03-21 14:38:54.310][Trace][635][885] HTTP client ip=172.17.0.1, request=0, to=15000ms
[2020-03-21 14:38:54.312][Trace][635][885] HTTP GET http://localhost:8080/live/livestream.flv, content-length=-1
[2020-03-21 14:38:54.312][Trace][635][885] dispatch cached gop success. count=12, duration=170
[2020-03-21 14:38:54.312][Trace][635][885] create consumer, active=1, queue_size=0.00, jitter=30000000
[2020-03-21 14:38:54.312][Trace][635][885] set fd=12, SO_SNDBUF=87040=>175000, buffer=350ms
[2020-03-21 14:38:54.312][Trace][635][885] FLV /live/livestream.flv, encoder=FLV, nodelay=0, mw_sleep=350ms, cache=0, msgs=128
[2020-03-21 14:38:54.313][Trace][635][885] FLV: write header audio=1, video=1
[2020-03-21 14:39:04.470][Trace][635][885] -> HTS http: got 23 msgs, age=10002522, min=8, mw=350
[2020-03-21 14:39:06.922][Trace][635][886] HTTP API DELETE http://localhost:1985/api/v1/clients/885?callback=angular.callbacks._2&method=DELETE, content-length=-1, chunked=0/0
[2020-03-21 14:39:06.922][Warn][635][886][11] kickoff client id=885 ok
[2020-03-21 14:39:09.376][Error][635][885][11] serve error code=1070 : mux serve : serve http : recv thread : coroutine cycle : pop message : timeout : interrupted
thread [635][885]: process_request() [src/app/srs_app_http_conn.cpp:162][errno=11]
thread [635][885]: serve_http() [src/protocol/srs_http_stack.cpp:712][errno=11]
thread [635][885]: do_serve_http() [src/app/srs_app_http_stream.cpp:651][errno=11]
thread [635][885]: cycle() [src/app/srs_app_st.cpp:200][errno=62]
thread [635][885]: cycle() [src/app/srs_app_recv_thread.cpp:601][errno=62]
thread [635][885]: pop_message() [src/app/srs_app_http_conn.cpp:213][errno=62]

TRANS_BY_GPT3