ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.86k stars 5.29k forks source link

SRT: Callback on_hls failed when disposing HLS. #3780

Closed winlinvip closed 10 months ago

winlinvip commented 10 months ago

Note: Please read FAQ before file an issue, see #2716

Description

Please description your issue here

  1. SRS Version: v5.9.170

  2. SRS Log:

[2023-08-22 12:02:11.620][INFO][40][x5l48q7b] SRT client ip=172.17.0.1:44780, fd=652451992
[2023-08-22 12:02:11.623][INFO][40][x5l48q7b] @srt, streamid=#!::r=live/stream-44572-2739617660809856576?secret=1ed8e0ffbc53439c8fc8da30ab8c19f0,m=publish, stream_url=/live/stream-44572-2739617660809856576, vhost=__defaultVhost__, app=live, stream=stream-44572-2739617660809856576, param=secret=1ed8e0ffbc53439c8fc8da30ab8c19f0
[2023-08-22 12:02:11.624][INFO][40][x5l48q7b] new srt source, stream_url=/live/stream-44572-2739617660809856576
[trace] 2023/08/22 12:02:11.629395 [52][1001] srs hooks ok, action=on_connect, vhost=__defaultVhost__, app=live, stream=stream-44572-2739617660809856576, param=secret=1ed8e0ffbc53439c8fc8da30ab8c19f0, server=vid-5d7dxn8, client=x5l48q7b, update=, {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_connect","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","tcUrl":"srt://172.17.0.2/live","pageUrl":""}
[2023-08-22 12:02:11.630][INFO][40][x5l48q7b] http: on_connect ok, client_id=x5l48q7b, url=http://localhost:2024/terraform/v1/hooks/srs/verify, request={"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_connect","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","tcUrl":"srt://172.17.0.2/live","pageUrl":""}, response={"code":0,"data":null,"server":52}
[trace] 2023/08/22 12:02:11.634113 [52][1001] srs hooks ok, action=on_publish, vhost=__defaultVhost__, app=live, stream=stream-44572-2739617660809856576, param=secret=1ed8e0ffbc53439c8fc8da30ab8c19f0, server=vid-5d7dxn8, client=x5l48q7b, update=2023-08-22T12:02:11Z, {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_publish","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}
[2023-08-22 12:02:11.636][INFO][40][x5l48q7b] http: on_publish ok, client_id=x5l48q7b, url=http://localhost:2024/terraform/v1/hooks/srs/verify, request={"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_publish","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}, response={"code":0,"data":null,"server":52}
[2023-08-22 12:02:11.637][INFO][40][x5l48q7b] new live source, stream_url=/live/stream-44572-2739617660809856576
[2023-08-22 12:02:11.643][INFO][40][x5l48q7b] new rtc source, stream_url=/live/stream-44572-2739617660809856576
[2023-08-22 12:02:11.646][INFO][40][x5l48q7b] RTC bridge from RTMP, rtmp2rtc=1, keep_bframe=0, merge_nalus=0
[2023-08-22 12:02:11.652][INFO][40][x5l48q7b] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=10000ms, dts_directly=1
[2023-08-22 12:02:11.653][INFO][40][x5l48q7b] ignore disabled exec for vhost=__defaultVhost__
[2023-08-22 12:02:11.654][INFO][40][x5l48q7b] http: mount flv stream for sid=/live/stream-44572-2739617660809856576, mount=/live/stream-44572-2739617660809856576.flv
[2023-08-22 12:02:11.658][INFO][40][x5l48q7b] 46B video sh,  codec(7, profile=High, level=3.2, 768x320, 0kbps, 0.0fps, 0.0s)
[2023-08-22 12:02:12.033][WARN][40][x5l48q7b][11] AUDIO: Timestamp 1760=>1434, may need mix_correct.
[2023-08-22 12:02:12.035][INFO][40][x5l48q7b] 4B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2023-08-22 12:02:12.044][INFO][40][x5l48q7b] RTMP2RTC: Init audio codec to 10(AAC)
[2023-08-22 12:02:22.857][INFO][40][x5l48q7b] <- SRT_CPB Transport Stats # pktRecv=589, pktRcvLoss=0, pktRcvRetrans=0, pktRcvDrop=0
[2023-08-22 12:02:22.858][INFO][40][x5l48q7b] <- SRT_CPB time=11215, packets=586, okbps=0,0,0, ikbps=0,0,0
[2023-08-22 12:02:23.185][WARN][40][x5l48q7b][11] srt to rtmp, audio duration=368ms too large, audio frames=16, may cause high latency and AV synchronization errors, read https://ossrs.io/lts/en-us/docs/v5/doc/srt-codec#ffmpeg-push-srt-stream

[2023-08-22 12:03:18.748][INFO][40][6498088c] hls cycle to dispose hls /live/stream-44572-2739617660809856576, timeout=10000000ms
[2023-08-22 12:03:18.752][WARN][40][6498088c][115] flush audio ignored, for segment is not open.
[2023-08-22 12:03:18.752][WARN][40][6498088c][115] ignore the segment close, for segment is not open.
[2023-08-22 12:03:19.013][INFO][40][6498088c] gracefully dispose hls /live/stream-44572-2739617660809856576

[trace] 2023/08/22 12:03:18.945331 [52][1001] on_hls ok, {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_hls","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","duration":14.72,"cwd":"/usr/local/srs-stack/platform","file":"./objs/nginx/html/live/stream-44572-2739617660809856576-0.ts","url":"live/stream-44572-2739617660809856576-0.ts","m3u8":"./objs/nginx/html/live/stream-44572-2739617660809856576.m3u8","m3u8_url":"live/stream-44572-2739617660809856576.m3u8","seq_no":0,"stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}
[2023-08-22 12:03:19.311][INFO][40][x5l48q7b] http: on_hls ok, client_id=x5l48q7b, url=http://localhost:2024/terraform/v1/hooks/srs/hls, request={"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_hls","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","duration":14.72,"cwd":"/usr/local/srs-stack/platform","file":"./objs/nginx/html/live/stream-44572-2739617660809856576-0.ts","url":"live/stream-44572-2739617660809856576-0.ts","m3u8":"./objs/nginx/html/live/stream-44572-2739617660809856576.m3u8","m3u8_url":"live/stream-44572-2739617660809856576.m3u8","seq_no":0,"stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}, response={"code":0,"data":null,"server":52}
[2023-08-22 12:03:20.309][WARN][40][x5l48q7b][11] ignore task failed code=4005(HttpStatus)(Invalid HTTP status code) : callback on_hls http://localhost:2024/terraform/v1/hooks/srs/hls : http: post http://localhost:2024/terraform/v1/hooks/srs/hls with {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_hls","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","duration":4.57,"cwd":"/usr/local/srs-stack/platform","file":"./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts","url":"live/stream-44572-2739617660809856576-1.ts","m3u8":"./objs/nginx/html/live/stream-44572-2739617660809856576.m3u8","m3u8_url":"live/stream-44572-2739617660809856576.m3u8","seq_no":1,"stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}, status=500, res=invalid ts file ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: stat ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: no such file or directory
thread [40][x5l48q7b]: call() [./src/app/srs_app_hls.cpp:122][errno=11]
thread [40][x5l48q7b]: on_hls() [./src/app/srs_app_http_hooks.cpp:401][errno=11]
thread [40][x5l48q7b]: do_post() [./src/app/srs_app_http_hooks.cpp:638][errno=11]

[error] 2023/08/22 12:03:20.076984 [52][1001] Serve /terraform/v1/hooks/srs/hls failed, err is stat ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: no such file or directory
invalid ts file ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts
main.handleOnHls.func1.1
    /g/platform/srs-hooks.go:684
main.handleOnHls.func1
    /g/platform/srs-hooks.go:720
net/http.HandlerFunc.ServeHTTP
    /usr/local/go/src/net/http/server.go:2084
net/http.(*ServeMux).ServeHTTP
    /usr/local/go/src/net/http/server.go:2462
net/http.serverHandler.ServeHTTP
    /usr/local/go/src/net/http/server.go:2916
net/http.(*conn).serve
    /usr/local/go/src/net/http/server.go:1966
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1571

[2023-08-22 12:03:20.350][INFO][40][x5l48q7b] cleanup when unpublish
[2023-08-22 12:03:20.369][INFO][40][x5l48q7b] cleanup when unpublish, created=1, deliver=1
[2023-08-22 12:03:20.377][WARN][40][x5l48q7b][4] 1 frames left in the queue on closing
[trace] 2023/08/22 12:03:20.613950 [52][1001] srs hooks ok, action=on_unpublish, vhost=__defaultVhost__, app=live, stream=stream-44572-2739617660809856576, param=secret=1ed8e0ffbc53439c8fc8da30ab8c19f0, server=vid-5d7dxn8, client=x5l48q7b, update=, {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_unpublish","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}
[2023-08-22 12:03:20.642][INFO][40][x5l48q7b] http: on_unpublish ok, client_id=x5l48q7b, url=http://localhost:2024/terraform/v1/hooks/srs/verify, request={"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_unpublish","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}, response={"code":0,"data":null,"server":52}
[trace] 2023/08/22 12:03:20.776245 [52][1001] srs hooks ok, action=on_close, vhost=__defaultVhost__, app=live, stream=, param=, server=vid-5d7dxn8, client=x5l48q7b, update=, {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_close","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","send_bytes":0,"recv_bytes":808400}
[2023-08-22 12:03:20.834][INFO][40][x5l48q7b] http: on_close ok, client_id=x5l48q7b, url=http://localhost:2024/terraform/v1/hooks/srs/verify, request={"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_close","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","send_bytes":0,"recv_bytes":808400}, response={"code":0,"data":null,"server":52}
[2023-08-22 12:03:20.883][INFO][40][x5l48q7b] SRT: before dispose resource(srt-ts-conn)(0x60d000078100), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-08-22 12:03:20.909][ERROR][40][x5l48q7b][11] srt serve error code=6001(SrtIo)(SRT read or write failed) : srt: recvmsg : srt_recvmsg, err=Operation not supported: Invalid socket ID
thread [40][x5l48q7b]: do_publishing() [./src/app/srs_app_srt_conn.cpp:467][errno=2]
thread [40][x5l48q7b]: recvmsg() [./src/protocol/srs_protocol_srt.cpp:796][errno=2](Resource temporarily unavailable)
[2023-08-22 12:03:20.918][INFO][40][x5l48q7b] SRT: disposing #0 resource(srt-ts-conn)(0x60d000078100), conns=1, disposing=1, zombies=0
[2023-08-22 12:03:20.924][INFO][40][x5l48q7b] close srt_fd=652451992

Detail log:

t.log

Expect

Should not fail.