AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.16k stars 336 forks source link

go2rtc does not recover connection to camera unless I restart go2rtc #762

Open felipecrs opened 9 months ago

felipecrs commented 9 months ago

I have a chinese ICSee/dvrip camera, which works great, including 2-way audio.

However, there is a problem: sometimes go2rtc loses the connection to it and it does not recover automatically, unless I manually restart go2rtc.

Camera is connected through Wi-Fi.

I am using go2rtc 1.8.3.

I have even built a Home Assistant automation to help me circumvent this problem:

# configuration.yaml

rest_command:
  restart_go2rtc:
    method: POST
    url: "http://ccab4aaf-frigate-beta:1984/api/restart"

automations:
  alias: Restart go2rtc when camera da rua becomes unavailable
  trigger:
    - platform: state
      entity_id:
        - camera.rua
      to: unavailable
      for:
        seconds: 10
  condition:
    - condition: state
      entity_id: sensor.frigate_status
      state: running        
  action:
    - service: rest_command.restart_go2rtc
  mode: single

My go2rtc config is:

go2rtc:
  streams:
    rua_h265:
      - rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=1&onvif=0.sdp?real_stream
      - ffmpeg:rua_h265#audio=aac
    rua:
      - ffmpeg:rua_h265#video=h264#hardware=vaapi
      - rtsp://127.0.0.1:8554/rua_h265?audio=all
      - dvrip://tema:pass@192.168.1.21:34567?backchannel=1
    rua_hd:
      # This stream is H265
      - rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=0&onvif=0.sdp?real_stream#media=video
      - rtsp://127.0.0.1:8554/rua_h265?audio=all

And I see these errors in my go2rtc logs:

2023-11-18 15:36:14.293907617  12:36:14.293 WRN [streams] json locked
2023-11-18 15:36:14.293910867  12:36:14.293 WRN [streams] json locked
2023-11-18 15:36:15.303973943  12:36:15.303 WRN [rtsp] error="streams: codecs not matched: H265, PCMA => AAC" stream=rua_h265
2023-11-18 15:36:15.305847379  12:36:15.305 WRN github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:225 > error="write tcp 127.0.0.1:8554->127.0.0.1:55914: write: broken pipe"
2023-11-18 15:36:35.818477295  12:36:35.818 WRN [rtsp] error="streams: codecs not matched: H265, PCMA => AAC" stream=rua_h265
2023-11-18 15:36:35.818646938  12:36:35.818 WRN github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:225 > error="write tcp 127.0.0.1:8554->127.0.0.1:39774: write: broken pipe"
2023-11-18 15:36:44.304954211  12:36:44.304 WRN [streams] json locked
2023-11-18 15:36:44.304969397  12:36:44.304 WRN [streams] json locked
2023-11-18 15:36:56.400898335  12:36:56.400 WRN [rtsp] error="streams: codecs not matched: H265, PCMA => AAC" stream=rua_h265
2023-11-18 15:36:56.401023228  12:36:56.400 WRN github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:225 > error="write tcp 127.0.0.1:8554->127.0.0.1:51050: write: broken pipe"
2023-11-18 15:37:14.331881702  12:37:14.320 WRN [streams] json locked
2023-11-18 15:37:14.331884919  12:37:14.320 WRN [streams] json locked
2023-11-18 15:37:37.485948322  12:37:37.485 WRN [rtsp] error="streams: codecs not matched: H265, PCMA => AAC" stream=rua_h265

If I scroll up for a while, I can also see:

url=rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=0&onvif=0.sdp?real_stream#media=video
2023-11-18 11:10:46.636306286  08:10:46.636 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="read tcp 172.30.33.6:37798->192.168.1.21:554: i/o timeout" url=rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=1&onvif=0.sdp?real_stream
2023-11-18 11:10:51.176080719  08:10:51.175 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="read tcp 172.30.33.6:34792->192.168.1.21:554: i/o timeout" url=rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=0&onvif=0.sdp?real_stream#media=video
2023-11-18 11:11:03.115253089  08:11:03.115 WRN [streams] json locked
2023-11-18 11:11:10.878418990  08:11:10.875 WRN [rtsp] error="streams: codecs not matched: H265, PCMA => AAC" stream=rua_h265

And if I scroll up a lot I can find this:

Click here to show ``` 2023-11-17 21:28:18.557372174 goroutine 280714 [IO wait]: 2023-11-17 21:28:18.557372981 internal/poll.runtime_pollWait(0x7ff1462e4870, 0x72) 2023-11-17 21:28:18.557373698 runtime/netpoll.go:343 +0x85 2023-11-17 21:28:18.557374541 internal/poll.(*pollDesc).wait(0xc078affe00?, 0xc07ae1e000?, 0x0) 2023-11-17 21:28:18.557375318 internal/poll/fd_poll_runtime.go:84 +0x27 2023-11-17 21:28:18.557376078 internal/poll.(*pollDesc).waitRead(...) 2023-11-17 21:28:18.557376802 internal/poll/fd_poll_runtime.go:89 2023-11-17 21:28:18.557377692 internal/poll.(*FD).Read(0xc078affe00, {0xc07ae1e000, 0x10000, 0x10000}) 2023-11-17 21:28:18.557378438 internal/poll/fd_unix.go:164 +0x27a 2023-11-17 21:28:18.557397859 net.(*netFD).Read(0xc078affe00, {0xc07ae1e000?, 0x4d4b45?, 0xc078da36e8?}) 2023-11-17 21:28:18.557398741 net/fd_posix.go:55 +0x25 2023-11-17 21:28:18.557399636 net.(*conn).Read(0xc0732502d8, {0xc07ae1e000?, 0xc04ce1b600?, 0x2?}) 2023-11-17 21:28:18.557400367 net/net.go:179 +0x45 2023-11-17 21:28:18.557401120 bufio.(*Reader).fill(0xc078b644e0) 2023-11-17 21:28:18.557401852 bufio/bufio.go:113 +0x103 2023-11-17 21:28:18.557402648 bufio.(*Reader).ReadSlice(0xc078b644e0, 0xb8?) 2023-11-17 21:28:18.557403367 bufio/bufio.go:379 +0x29 2023-11-17 21:28:18.557404122 bufio.(*Reader).ReadLine(0xc078b644e0) 2023-11-17 21:28:18.557404823 bufio/bufio.go:408 +0x25 2023-11-17 21:28:18.557405654 net/textproto.(*Reader).readLineSlice(0xc078da3970) 2023-11-17 21:28:18.557406375 net/textproto/reader.go:56 +0x99 2023-11-17 21:28:18.557407098 net/textproto.(*Reader).ReadLine(...) 2023-11-17 21:28:18.557407810 net/textproto/reader.go:39 2023-11-17 21:28:18.557426620 github.com/AlexxIT/go2rtc/pkg/tcp.ReadResponse(0xc078b644e0) 2023-11-17 21:28:18.557427650 github.com/AlexxIT/go2rtc/pkg/tcp/textproto.go:46 +0x54 2023-11-17 21:28:18.557428549 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).ReadResponse(0xc07ad84000) 2023-11-17 21:28:18.557429362 github.com/AlexxIT/go2rtc/pkg/rtsp/conn.go:366 +0x77 2023-11-17 21:28:18.557430278 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Do(0xc07ad84000, 0xc07aae0640) 2023-11-17 21:28:18.557431101 github.com/AlexxIT/go2rtc/pkg/rtsp/client.go:65 +0x34 2023-11-17 21:28:18.557432060 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Describe(0xc07ad84000) 2023-11-17 21:28:18.557432903 github.com/AlexxIT/go2rtc/pkg/rtsp/client.go:134 +0x2de 2023-11-17 21:28:18.557433874 github.com/AlexxIT/go2rtc/internal/rtsp.rtspHandler({0xc0000ccb40?, 0xc00009ffb0?}) 2023-11-17 21:28:18.557434719 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:126 +0x2f8 2023-11-17 21:28:18.557435612 github.com/AlexxIT/go2rtc/internal/streams.GetProducer({0xc0000ccb40, 0x28}) 2023-11-17 21:28:18.557436469 github.com/AlexxIT/go2rtc/internal/streams/handlers.go:49 +0xcb 2023-11-17 21:28:18.557437378 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000debd0) 2023-11-17 21:28:18.557438216 github.com/AlexxIT/go2rtc/internal/streams/producer.go:62 +0x95 2023-11-17 21:28:18.557460453 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3cc0, {0xd2b760, 0xc00104e480}) 2023-11-17 21:28:18.557461523 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557462446 github.com/AlexxIT/go2rtc/internal/mp4.handlerWSMSE(0xc07a6fe3c0, 0xc078d4fec0) 2023-11-17 21:28:18.557463253 github.com/AlexxIT/go2rtc/internal/mp4/ws.go:31 +0x545 2023-11-17 21:28:18.557464073 github.com/AlexxIT/go2rtc/internal/api/ws.apiWS.func2() 2023-11-17 21:28:18.557464896 github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:130 +0x39 2023-11-17 21:28:18.557465825 created by github.com/AlexxIT/go2rtc/internal/api/ws.apiWS in goroutine 280712 2023-11-17 21:28:18.557466672 github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:129 +0x365 2023-11-17 21:28:18.557467268 2023-11-17 21:28:18.557467958 goroutine 280624 [runnable]: 2023-11-17 21:28:18.557468748 internal/poll.runtime_pollWait(0x7ff146384c28, 0x72) 2023-11-17 21:28:18.557469451 runtime/netpoll.go:343 +0x85 2023-11-17 21:28:18.557470289 internal/poll.(*pollDesc).wait(0xc078afec80?, 0xc070ccb900?, 0x0) 2023-11-17 21:28:18.557471052 internal/poll/fd_poll_runtime.go:84 +0x27 2023-11-17 21:28:18.557471800 internal/poll.(*pollDesc).waitRead(...) 2023-11-17 21:28:18.557472550 internal/poll/fd_poll_runtime.go:89 2023-11-17 21:28:18.557491977 internal/poll.(*FD).Read(0xc078afec80, {0xc070ccb900, 0x2, 0x2}) 2023-11-17 21:28:18.557492935 internal/poll/fd_unix.go:164 +0x27a 2023-11-17 21:28:18.557493867 net.(*netFD).Read(0xc078afec80, {0xc070ccb900?, 0x7ff1471001d8?, 0x7ff192c9c108?}) 2023-11-17 21:28:18.557494620 net/fd_posix.go:55 +0x25 2023-11-17 21:28:18.557495526 net.(*conn).Read(0xc07c7d3c30, {0xc070ccb900?, 0xb01be0?, 0x7ff192c9c101?}) 2023-11-17 21:28:18.557496216 net/net.go:179 +0x45 2023-11-17 21:28:18.557497219 github.com/pion/ice/v2.readStreamingPacket({0xd31d90, 0xc07c7d3c30}, {0xc079138000, 0x0?, 0x2000}) 2023-11-17 21:28:18.557498039 github.com/pion/ice/v2@v2.3.11/tcp_mux.go:362 +0x9b 2023-11-17 21:28:18.557498964 github.com/pion/ice/v2.(*TCPMuxDefault).handleConn(0xc00020c400, {0xd31d90?, 0xc07c7d3c30}) 2023-11-17 21:28:18.557499776 github.com/pion/ice/v2@v2.3.11/tcp_mux.go:168 +0x8d 2023-11-17 21:28:18.557519094 github.com/pion/ice/v2.(*TCPMuxDefault).start.func1() 2023-11-17 21:28:18.557520068 github.com/pion/ice/v2@v2.3.11/tcp_mux.go:93 +0x57 2023-11-17 21:28:18.557521029 created by github.com/pion/ice/v2.(*TCPMuxDefault).start in goroutine 20 2023-11-17 21:28:18.557521833 github.com/pion/ice/v2@v2.3.11/tcp_mux.go:91 +0xbb 2023-11-17 21:28:18.557522437 2023-11-17 21:28:18.557523152 goroutine 280727 [chan receive]: 2023-11-17 21:28:18.557524071 github.com/pion/srtp/v2.(*SessionSRTP).AcceptStream(0x48941d1c3ce8003e?) 2023-11-17 21:28:18.557524916 github.com/pion/srtp/v2@v2.0.18/session_srtp.go:98 +0x26 2023-11-17 21:28:18.557525974 github.com/pion/webrtc/v3.(*PeerConnection).undeclaredRTPMediaProcessor(0xc002606900) 2023-11-17 21:28:18.557526876 github.com/pion/webrtc/v3@v3.2.22/peerconnection.go:1650 +0xd1 2023-11-17 21:28:18.557547516 created by github.com/pion/webrtc/v3.(*PeerConnection).undeclaredMediaProcessor in goroutine 280663 2023-11-17 21:28:18.557548531 github.com/pion/webrtc/v3@v3.2.22/peerconnection.go:1637 +0x56 2023-11-17 21:28:18.557549167 2023-11-17 21:28:18.557549870 goroutine 280728 [chan receive]: 2023-11-17 21:28:18.557550763 github.com/pion/srtp/v2.(*SessionSRTCP).AcceptStream(0xb358a78cd7d00e7e?) 2023-11-17 21:28:18.557551607 github.com/pion/srtp/v2@v2.0.18/session_srtcp.go:96 +0x26 2023-11-17 21:28:18.557552539 github.com/pion/webrtc/v3.(*PeerConnection).undeclaredRTCPMediaProcessor(0xc002606900) 2023-11-17 21:28:18.557553396 github.com/pion/webrtc/v3@v3.2.22/peerconnection.go:1694 +0x119 2023-11-17 21:28:18.557554423 created by github.com/pion/webrtc/v3.(*PeerConnection).undeclaredMediaProcessor in goroutine 280663 2023-11-17 21:28:18.557555276 github.com/pion/webrtc/v3@v3.2.22/peerconnection.go:1638 +0x96 2023-11-17 21:28:18.557555872 2023-11-17 21:28:18.557556547 goroutine 280715 [select]: 2023-11-17 21:28:18.557577139 github.com/AlexxIT/go2rtc/internal/exec.handleRTSP({0xc078eafa00, 0x1e1}, {0xc075f77170, 0x21}, 0xc07ad842c0) 2023-11-17 21:28:18.557578164 github.com/AlexxIT/go2rtc/internal/exec/exec.go:127 +0x44e 2023-11-17 21:28:18.557579113 github.com/AlexxIT/go2rtc/internal/exec.execHandle({0xc078eafa00, 0x1e1}) 2023-11-17 21:28:18.557579987 github.com/AlexxIT/go2rtc/internal/exec/exec.go:73 +0x234 2023-11-17 21:28:18.557580932 github.com/AlexxIT/go2rtc/internal/streams.GetProducer({0xc078eafa00, 0x1e1}) 2023-11-17 21:28:18.557581777 github.com/AlexxIT/go2rtc/internal/streams/handlers.go:49 +0xcb 2023-11-17 21:28:18.557582700 github.com/AlexxIT/go2rtc/internal/streams.GetProducer({0xc0000ccb10, 0x29}) 2023-11-17 21:28:18.557583569 github.com/AlexxIT/go2rtc/internal/streams/handlers.go:44 +0xd6 2023-11-17 21:28:18.557584504 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000deb40) 2023-11-17 21:28:18.557585373 github.com/AlexxIT/go2rtc/internal/streams/producer.go:62 +0x95 2023-11-17 21:28:18.557586396 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3cc0, {0xd2b940, 0xc00019e3c0}) 2023-11-17 21:28:18.557605948 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557607061 github.com/AlexxIT/go2rtc/internal/webrtc.asyncHandler(0xc07a6fe3c0, 0xc078d4fee0) 2023-11-17 21:28:18.557607930 github.com/AlexxIT/go2rtc/internal/webrtc/webrtc.go:171 +0x6a5 2023-11-17 21:28:18.557608777 github.com/AlexxIT/go2rtc/internal/api/ws.apiWS.func2() 2023-11-17 21:28:18.557609634 github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:130 +0x39 2023-11-17 21:28:18.557610532 created by github.com/AlexxIT/go2rtc/internal/api/ws.apiWS in goroutine 280712 2023-11-17 21:28:18.557630936 github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:129 +0x365 2023-11-17 21:28:18.557631722 2023-11-17 21:28:18.557632475 goroutine 280772 [sync.Mutex.Lock]: 2023-11-17 21:28:18.557633339 sync.runtime_SemacquireMutex(0xc24fb8?, 0x19?, 0x3e4df2a62c068770?) 2023-11-17 21:28:18.557634037 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.557634760 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.557635485 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.557636178 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.557636834 sync/mutex.go:90 2023-11-17 21:28:18.557637712 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.557638543 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.557639537 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc07a0b3e40}) 2023-11-17 21:28:18.557640415 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557659774 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.557660774 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.557661609 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.557662430 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.557663306 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07a0b3e40) 2023-11-17 21:28:18.557664133 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.557665011 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07a0b3e40) 2023-11-17 21:28:18.557665839 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.557666748 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.557667605 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.557668193 2023-11-17 21:28:18.557668863 goroutine 280687 [select]: 2023-11-17 21:28:18.557669902 github.com/pion/interceptor/pkg/report.(*SenderInterceptor).loop(0xc078bfca80, {0xd28840, 0xc078e030a0}) 2023-11-17 21:28:18.557690766 github.com/pion/interceptor@v0.1.25/pkg/report/sender_interceptor.go:116 +0x1ee 2023-11-17 21:28:18.557691959 created by github.com/pion/interceptor/pkg/report.(*SenderInterceptor).BindRTCPWriter in goroutine 280715 2023-11-17 21:28:18.557692925 github.com/pion/interceptor@v0.1.25/pkg/report/sender_interceptor.go:100 +0x12b 2023-11-17 21:28:18.557693501 2023-11-17 21:28:18.557694154 goroutine 280688 [select]: 2023-11-17 21:28:18.557695134 github.com/pion/interceptor/pkg/twcc.(*SenderInterceptor).loop(0xc078e2e3c0, {0xd28840, 0xc078e030a0}) 2023-11-17 21:28:18.557696053 github.com/pion/interceptor@v0.1.25/pkg/twcc/sender_interceptor.go:180 +0xe6 2023-11-17 21:28:18.557697076 created by github.com/pion/interceptor/pkg/twcc.(*SenderInterceptor).BindRTCPWriter in goroutine 280715 2023-11-17 21:28:18.557698003 github.com/pion/interceptor@v0.1.25/pkg/twcc/sender_interceptor.go:93 +0x16b 2023-11-17 21:28:18.557698600 2023-11-17 21:28:18.557699318 goroutine 280653 [sync.Mutex.Lock]: 2023-11-17 21:28:18.557700212 sync.runtime_SemacquireMutex(0xc24fb8?, 0x19?, 0x3e4df2a600126620?) 2023-11-17 21:28:18.557700928 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.557701668 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.557702347 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.557703027 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.557723676 sync/mutex.go:90 2023-11-17 21:28:18.557724741 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.557725624 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.557726628 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc078b63760}) 2023-11-17 21:28:18.557727519 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557728449 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.557729277 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.557730097 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.557730884 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.557731723 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc078b63760) 2023-11-17 21:28:18.557732568 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.557733423 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc078b63760) 2023-11-17 21:28:18.557734277 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.557735184 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.557736034 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.557736628 2023-11-17 21:28:18.557757658 goroutine 280774 [runnable]: 2023-11-17 21:28:18.557759053 syscall.Syscall6(0x87c1112afeff6225?, 0xa737d3808d743b53?, 0x754f82f09dfec291?, 0xd4d960763f758f79?, 0x305bd184b56ce1e7?, 0xfbbb82f6a80ee410?, 0x60a7876b?) 2023-11-17 21:28:18.557759822 syscall/syscall_linux.go:91 +0x30 2023-11-17 21:28:18.557760629 os.(*Process).blockUntilWaitable(0xc075f771a0) 2023-11-17 21:28:18.557761353 os/wait_waitid.go:32 +0x76 2023-11-17 21:28:18.557762064 os.(*Process).wait(0xc075f771a0) 2023-11-17 21:28:18.557762774 os/exec_unix.go:22 +0x25 2023-11-17 21:28:18.557763454 os.(*Process).Wait(...) 2023-11-17 21:28:18.557764100 os/exec.go:134 2023-11-17 21:28:18.557764819 os/exec.(*Cmd).Wait(0xc07ad842c0) 2023-11-17 21:28:18.557765501 os/exec/exec.go:890 +0x45 2023-11-17 21:28:18.557766327 github.com/AlexxIT/go2rtc/internal/exec.handleRTSP.func2() 2023-11-17 21:28:18.557767168 github.com/AlexxIT/go2rtc/internal/exec/exec.go:118 +0x36 2023-11-17 21:28:18.557768118 created by github.com/AlexxIT/go2rtc/internal/exec.handleRTSP in goroutine 280715 2023-11-17 21:28:18.557768931 github.com/AlexxIT/go2rtc/internal/exec/exec.go:117 +0x3a6 2023-11-17 21:28:18.557769517 2023-11-17 21:28:18.557770194 goroutine 280771 [IO wait]: 2023-11-17 21:28:18.557790733 internal/poll.runtime_pollWait(0x7ff1462e4a60, 0x72) 2023-11-17 21:28:18.557791634 runtime/netpoll.go:343 +0x85 2023-11-17 21:28:18.557792545 internal/poll.(*pollDesc).wait(0xc078d53c00?, 0xc07acde000?, 0x0) 2023-11-17 21:28:18.557793295 internal/poll/fd_poll_runtime.go:84 +0x27 2023-11-17 21:28:18.557794076 internal/poll.(*pollDesc).waitRead(...) 2023-11-17 21:28:18.557794834 internal/poll/fd_poll_runtime.go:89 2023-11-17 21:28:18.557795731 internal/poll.(*FD).Read(0xc078d53c00, {0xc07acde000, 0x10000, 0x10000}) 2023-11-17 21:28:18.557796480 internal/poll/fd_unix.go:164 +0x27a 2023-11-17 21:28:18.557797358 net.(*netFD).Read(0xc078d53c00, {0xc07acde000?, 0x0?, 0xc000000001?}) 2023-11-17 21:28:18.557798072 net/fd_posix.go:55 +0x25 2023-11-17 21:28:18.557798908 net.(*conn).Read(0xc0732502d0, {0xc07acde000?, 0x0?, 0xc076a69580?}) 2023-11-17 21:28:18.557799556 net/net.go:179 +0x45 2023-11-17 21:28:18.557800269 bufio.(*Reader).fill(0xc078b64480) 2023-11-17 21:28:18.557823980 bufio/bufio.go:113 +0x103 2023-11-17 21:28:18.557824967 bufio.(*Reader).ReadSlice(0xc078b64480, 0xa8?) 2023-11-17 21:28:18.557825710 bufio/bufio.go:379 +0x29 2023-11-17 21:28:18.557826460 bufio.(*Reader).ReadLine(0xc078b64480) 2023-11-17 21:28:18.557827163 bufio/bufio.go:408 +0x25 2023-11-17 21:28:18.557827973 net/textproto.(*Reader).readLineSlice(0xc076a69788) 2023-11-17 21:28:18.557828712 net/textproto/reader.go:56 +0x99 2023-11-17 21:28:18.557829455 net/textproto.(*Reader).ReadLine(...) 2023-11-17 21:28:18.557830153 net/textproto/reader.go:39 2023-11-17 21:28:18.557830986 github.com/AlexxIT/go2rtc/pkg/tcp.ReadResponse(0xc078b64480) 2023-11-17 21:28:18.557831811 github.com/AlexxIT/go2rtc/pkg/tcp/textproto.go:46 +0x54 2023-11-17 21:28:18.557832694 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).ReadResponse(0xc079b58f20) 2023-11-17 21:28:18.557833504 github.com/AlexxIT/go2rtc/pkg/rtsp/conn.go:366 +0x77 2023-11-17 21:28:18.557834410 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Do(0xc079b58f20, 0xc07aae0460) 2023-11-17 21:28:18.557835230 github.com/AlexxIT/go2rtc/pkg/rtsp/client.go:65 +0x34 2023-11-17 21:28:18.557836105 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Describe(0xc079b58f20) 2023-11-17 21:28:18.557836897 github.com/AlexxIT/go2rtc/pkg/rtsp/client.go:134 +0x2de 2023-11-17 21:28:18.557856988 github.com/AlexxIT/go2rtc/internal/rtsp.rtspHandler({0xc0000ccae0?, 0xc00009ffb0?}) 2023-11-17 21:28:18.557858018 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:126 +0x2f8 2023-11-17 21:28:18.557858944 github.com/AlexxIT/go2rtc/internal/streams.GetProducer({0xc0000ccae0, 0x28}) 2023-11-17 21:28:18.557859822 github.com/AlexxIT/go2rtc/internal/streams/handlers.go:49 +0xcb 2023-11-17 21:28:18.557860725 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000df0e0) 2023-11-17 21:28:18.557861616 github.com/AlexxIT/go2rtc/internal/streams/producer.go:62 +0x95 2023-11-17 21:28:18.557862644 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3e00, {0xd2b910, 0xc07a0b3ce0}) 2023-11-17 21:28:18.557863548 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557864488 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.557865376 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.557866205 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.557867090 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.557867959 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07a0b3ce0) 2023-11-17 21:28:18.557887199 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.557888229 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07a0b3ce0) 2023-11-17 21:28:18.557889145 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.557890071 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.557890900 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.557891491 2023-11-17 21:28:18.557892204 goroutine 280769 [sync.Mutex.Lock]: 2023-11-17 21:28:18.557893056 sync.runtime_SemacquireMutex(0xc24fb8?, 0x19?, 0x3e4df2a600c000e0?) 2023-11-17 21:28:18.557893769 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.557894527 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.557895210 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.557895895 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.557896553 sync/mutex.go:90 2023-11-17 21:28:18.557897457 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.557898322 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.557899348 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc07a0b2840}) 2023-11-17 21:28:18.557921174 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557922278 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.557923158 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.557923978 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.557924783 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.557925618 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07a0b2840) 2023-11-17 21:28:18.557926465 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.557927291 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07a0b2840) 2023-11-17 21:28:18.557928139 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.557929032 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.557929863 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.557930460 2023-11-17 21:28:18.557931160 goroutine 280740 [chan receive]: 2023-11-17 21:28:18.557932012 github.com/AlexxIT/go2rtc/pkg/core.(*Sender).HandleRTP.func1() 2023-11-17 21:28:18.557932834 github.com/AlexxIT/go2rtc/pkg/core/track.go:142 +0x71 2023-11-17 21:28:18.557933743 created by github.com/AlexxIT/go2rtc/pkg/core.(*Sender).HandleRTP in goroutine 280756 2023-11-17 21:28:18.557934559 github.com/AlexxIT/go2rtc/pkg/core/track.go:140 +0x359 2023-11-17 21:28:18.557935156 2023-11-17 21:28:18.557954423 goroutine 280739 [sync.Mutex.Lock]: 2023-11-17 21:28:18.557955462 sync.runtime_SemacquireMutex(0x7ff192c9ca68?, 0x10?, 0xc000091800?) 2023-11-17 21:28:18.557956220 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.557956981 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.557957673 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.557958355 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.557959034 sync/mutex.go:90 2023-11-17 21:28:18.557959941 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.557960803 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.557961845 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc07a8e3600}) 2023-11-17 21:28:18.557962711 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.557963616 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.557964444 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.557965263 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.557984501 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.557985521 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07a8e3600) 2023-11-17 21:28:18.557986364 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.557987190 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07a8e3600) 2023-11-17 21:28:18.557988038 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.557988971 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.557989837 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.557990440 2023-11-17 21:28:18.557991139 goroutine 280655 [sync.Mutex.Lock]: 2023-11-17 21:28:18.557991973 sync.runtime_SemacquireMutex(0xc24fb8?, 0x19?, 0x3e4df2a600126620?) 2023-11-17 21:28:18.557992685 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.557993421 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.557994111 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.557994820 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.557995481 sync/mutex.go:90 2023-11-17 21:28:18.557996376 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.557997247 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.558020002 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc07acdb1e0}) 2023-11-17 21:28:18.558021080 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.558022023 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.558022865 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.558023694 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.558024487 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.558025309 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07acdb1e0) 2023-11-17 21:28:18.558026120 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.558026939 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07acdb1e0) 2023-11-17 21:28:18.558027775 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.558028710 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.558029546 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.558030140 2023-11-17 21:28:18.558030836 goroutine 280744 [sync.Mutex.Lock]: 2023-11-17 21:28:18.558031674 sync.runtime_SemacquireMutex(0x7ff192c9ca68?, 0x10?, 0xc000282c00?) 2023-11-17 21:28:18.558032385 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.558052832 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.558053736 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.558054461 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.558055117 sync/mutex.go:90 2023-11-17 21:28:18.558056036 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.558056906 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.558057950 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc0794c7b80}) 2023-11-17 21:28:18.558058851 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.558059755 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.558060567 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.558061383 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.558062181 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.558063033 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc0794c7b80) 2023-11-17 21:28:18.558063867 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.558064726 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc0794c7b80) 2023-11-17 21:28:18.558065547 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.558084510 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.558085557 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:18.558086177 2023-11-17 21:28:18.558086875 goroutine 280745 [sync.Mutex.Lock]: 2023-11-17 21:28:18.558087737 sync.runtime_SemacquireMutex(0xc24fb8?, 0x19?, 0x3e4df2a62c068770?) 2023-11-17 21:28:18.558088414 runtime/sema.go:77 +0x25 2023-11-17 21:28:18.558089172 sync.(*Mutex).lockSlow(0xc0000de85c) 2023-11-17 21:28:18.558089875 sync/mutex.go:171 +0x15d 2023-11-17 21:28:18.558090559 sync.(*Mutex).Lock(...) 2023-11-17 21:28:18.558091250 sync/mutex.go:90 2023-11-17 21:28:18.558092089 github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0000de7e0) 2023-11-17 21:28:18.558092939 github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52 2023-11-17 21:28:18.558093933 github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc0000c3b40, {0xd2b910, 0xc07bf00420}) 2023-11-17 21:28:18.558094792 github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:26 +0x4c7 2023-11-17 21:28:18.558095716 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler.func1({0xb018a0?, 0xd24e80?}) 2023-11-17 21:28:18.558211282 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:191 +0x605 2023-11-17 21:28:18.558213055 github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...) 2023-11-17 21:28:18.558213898 github.com/AlexxIT/go2rtc/pkg/core/listener.go:16 2023-11-17 21:28:18.558214781 github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Accept(0xc07bf00420) 2023-11-17 21:28:18.558215628 github.com/AlexxIT/go2rtc/pkg/rtsp/server.go:97 +0xc02 2023-11-17 21:28:18.558216500 github.com/AlexxIT/go2rtc/internal/rtsp.tcpHandler(0xc07bf00420) 2023-11-17 21:28:18.558217399 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:223 +0x198 2023-11-17 21:28:18.558218354 created by github.com/AlexxIT/go2rtc/internal/rtsp.Init.func1 in goroutine 19 2023-11-17 21:28:18.558219201 github.com/AlexxIT/go2rtc/internal/rtsp/rtsp.go:75 +0x45 2023-11-17 21:28:19.012546334 curl: (56) Recv failure: Connection reset by peer 2023-11-17 21:28:19.012550118 [ERROR] The go2rtc service is not responding to ping, restarting... 2023-11-17 21:28:19.081913903 [INFO] The go2rtc service exited with code 2 (by signal 0) 2023-11-17 21:28:20.098833512 [WARN] Using go2rtc binary from '/config/go2rtc' instead of the embedded one 2023-11-17 21:28:20.098857957 [INFO] Starting go2rtc... 2023-11-17 21:28:20.166347356 18:28:20.166 INF go2rtc version 1.8.3 linux/amd64 2023-11-17 21:28:20.166776550 18:28:20.166 INF [api] listen addr=:1984 2023-11-17 21:28:20.166971173 18:28:20.166 INF [rtsp] listen addr=:8554 2023-11-17 21:28:20.167185911 18:28:20.167 INF [webrtc] listen addr=:8555 2023-11-18 01:32:27.589309514 22:32:27.589 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="read tcp 172.30.33.6:37414->192.168.1.21:554: i/o timeout" url=rtsp://192.168.1.21/user=tema_password=pass_channel=0_stream=1&onvif=0.sdp?real_stream ```

But this one even made go2rtc crash and get stuck, which caused the go2rtc watchdog from Frigate to restart it. I am not sure if it is directly related with the problem that I am reporting itself.

Another note is that, previously, preloading the stream in Home Assistant was apparently enough to solve this problem, but it no longer is. go2rtc loses the connection and does not recover even if Frigate is consuming the stream 100% of the time.

felipecrs commented 9 months ago

I have some update to provide. Preloading the stream indeed fixes the issue for me, however, there is a catch, you must not have any other source in the stream you are preloading. For example:

streams:
  rua_h265:
    - rtsp://192.168.1.21/user=tema_password=admin_channel=0_stream=1&onvif=0.sdp?real_stream
    - ffmpeg:rua_h265#audio=aac

Preloading this stream makes no difference as to make the stream available or not. That's probably because go2rtc detects that there is already a stream working (the ffmpeg stream) and won't retry the first stream in case it breaks.

This is why it had stopped working for me, because I had added such ffmpeg: stream source.

However, preloading this:

streams:
  rua_h265:
    - rtsp://192.168.1.21/user=tema_password=admin_channel=0_stream=1&onvif=0.sdp?real_stream

Indeed helps. The stream never breaks or is retried automatically without having to restart go2rtc itself.

ivanjx commented 9 months ago

im also having trouble cant reconnect to camera if the camera is restarted. previously on my custom app with ffmpeg i stopped the ffmpeg process itself when no frame/data is received but in case of go2rtc it wont and keeps hanging forever.

streams:
        ffmpeg:
            cam1: "-avoid_negative_ts make_zero -err_detect aggressive -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -rtsp_transport udp -min_port 5011 -max_port 5015 -i {input}"
        cam1:
            - "ffmpeg:rtsp://user:pass@192.168.20.21/stream1#input=cam1#video=copy#audio=aac"
ivanjx commented 9 months ago

@felipecrs i am trying your automation script but i am having trouble in finding sensor.frigate_status. is there a way or tutorial to add this?

felipecrs commented 9 months ago

It's provided by the Frigate integration, you may need to enable it. But I have to say that I'm not longer using such automation. It didn't work as good as the other method I mentioned today.

ivanjx commented 9 months ago

unfortunately i cant have stream preloading since i need the ffmpeg: directive in the source

ivanjx commented 9 months ago

also my camera state never goes to unavailable even though frigate says it is not receiving any data from it.

felipecrs commented 9 months ago

Ops, I forgot to mention that I'm running Frigate 0.13 :P

ivanjx commented 9 months ago

@felipecrs are you using the master branch of the hass integration? i am already on 0.13 beta

felipecrs commented 9 months ago

No, I'm just using the latest beta integration.

felipecrs commented 9 months ago

image

ivanjx commented 9 months ago

thanks @felipecrs the problem was i was using the master branch for the integration. swithced to dev branch adds the unavailable status for the camera. image

ivanjx commented 9 months ago

the problem with this approach is sometimes (like 50% of the time) frigate just hangs. i hope there will be an api to restart the go2rtc only.

felipecrs commented 9 months ago

(?) My automation restarts go2rtc only.

ivanjx commented 9 months ago

oh the port 1984 is only for gortc? i am using frigate docker

AlexxIT commented 8 months ago

@felipecrs are you sure about your go2rtc config? I can see in the go2rtc logs:

2023-11-17 21:28:19.012546334  curl: (56) Recv failure: Connection reset by peer

I think it's your exec command for Dahua doorbell.

felipecrs commented 8 months ago

I am pretty sure it is the correct config. This one is from my brother's house, and he does not have a Dahua doorbell.

About the curl, I believe it came from the go2rtc_healthcheck from Frigate:

https://github.com/blakeblackshear/frigate/blob/64bee7a64fd24faca4b4bb3e099e224e9e2cc9f3/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run#L15

It prints the logs to the same channel as go2rtc itself, that's why.

AlexxIT commented 8 months ago

Are you sure this is start of error?

2023-11-17 21:28:18.557372174  goroutine 280714 [IO wait]:
felipecrs commented 8 months ago

Actually no... However I see that the log repeats, you can see that goroutine [IO wait] appears again the logs below. I thought it was just repeating so I stopped scrolling up to collect it.

Please let me know if you want me to capture full logs.

AlexxIT commented 8 months ago

This is info about all blocked routines. But we don't know the reason.

felipecrs commented 8 months ago

Got it. I got full logs now. I opened a separate issue to talk about the panic because I am not sure it is directly related to this sympthom:

felipecrs commented 2 months ago

I noticed this issue had gone better with the updates. However, I tested for days and noticed that 1.9.4 is worse than 1.9.3 in this regard. With 1.9.3, I did not catch this issue in 3 days. With 1.9.4 I caught this issue twice a day.

EricCorleone commented 2 weeks ago

To solve this I use HA automation to restart go2rtc addon every 10 minutes, and everything works fine now lol