bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.7k stars 1.47k forks source link

Panic when RTSP stream closes #2275

Closed XPav closed 1 year ago

XPav commented 1 year ago

Which version are you using?

v1.0+

Which operating system are you using?

Describe the issue

Media MTX crashes when an RTSP stream closes.

Describe how to replicate the issue

Start the server.

Publish stream with videotestsrc pattern=smpte100 is-live=true ! video/x-raw,width=1280,height=720,framerate=30/1 ! timeoverlay ^ ! x264enc bitrate=4000 tune=zerolatency key-int-max=30 ! video/x-h264, profile=baseline ! queue ^ ! rtspclientsink location=rtsp://localhost:8554/test

See stream go into server.
Ctrl-C gstreamer.

Server crashes/

`2023/09/01 09:47:35 INF [RTSP] [session 0671b56f] is publishing to path 'test', 1 track (H264) panic: close of closed channel

goroutine 74 [running]: github.com/bluenviron/gortsplib/v4/pkg/rtcpreceiver.(RTCPReceiver).Close(...) /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/pkg/rtcpreceiver/rtcpreceiver.go:99 github.com/bluenviron/gortsplib/v4.(serverSessionFormat).stop(...) 108 +0x11c github.com/bluenviron/gortsplib/v4.(*ServerSession).run(0xc000276640) /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session.go:345 +0x1c6 created by github.com/bluenviron/gortsplib/v4.newServerSession /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session.go:224 +0x41c`

Did you attach the server logs?

yes

Did you attach a network dump?

no

babaee74 commented 1 year ago

Hi is there any update on this? when I stream a video using gstreamer to the server, server closes after the video is finished:

I am using the binary files this is the error it throws:

goroutine 60 [running]:
github.com/bluenviron/gortsplib/v4/pkg/rtcpreceiver.(*RTCPReceiver).Close(...)
    /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/pkg/rtcpreceiver/rtcpreceiver.go:99
github.com/bluenviron/gortsplib/v4.(*serverSessionFormat).stop(...)
    /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session_format.go:60
github.com/bluenviron/gortsplib/v4.(*serverSessionMedia).stop(0xc00049e880?)
    /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session_media.go:108 +0x11c
github.com/bluenviron/gortsplib/v4.(*ServerSession).run(0xc00029c500)
    /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session.go:345 +0x1c6
created by github.com/bluenviron/gortsplib/v4.newServerSession
    /go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.0.0-20230830092337-fc0c24278931/server_session.go:224 +0x41c
aler9 commented 1 year ago

fixed in v1.0.2

babaee74 commented 1 year ago

That was quick! thanks, it works great

github-actions[bot] commented 6 months ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.