AlexxIT / WebRTC

Home Assistant custom component for real-time viewing of almost any camera stream using WebRTC and other technologies.
https://github.com/AlexxIT/Blog
MIT License
1.46k stars 173 forks source link

Failed to start WebRTC stream: RTSPtoWeb server communication failure: Cannot connect to host 127.0.0.1:8083 ssl:default [Connect call failed ('127.0.0.1', 8083)] #341

Closed alexruffell closed 2 years ago

alexruffell commented 2 years ago

I have several 4K Hikvision cameras integrated using the default Home Assistant Camera integration. I also have a Unifi doorbell which is integrated both via Unifi Protect and the default Home Assistant Camera integration.

Recently I started having an issue with displaying the doorbell and one of my drive way cameras. The log shows this and the WebRTC add-on is not running. I have no idea what it means or what to do about it.

time="2022-08-14T17:27:14-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:17-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:20-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:23-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:26-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:29-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:32-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:35-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:38-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:41-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:44-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:47-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:50-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
time="2022-08-14T17:27:52-05:00" level=error msg="Stream error restart stream stream stop rtsp signal" call=Restart
panic: runtime error: index out of range [2] with length 2
goroutine 72637 [running]:
github.com/deepch/vdk/codec/h264parser.NewCodecDataFromSPSAndPPS(0xc03cc5c313, 0x2, 0x5f1, 0xc038afab50, 0x12b, 0x12b, 0x0, 0x0, 0x0, 0x0, ...)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/codec/h264parser/parser.go:704 +0x410
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).CodecUpdateSPS(0xc000376200, 0xc03cc5c313, 0x2, 0x5f1)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:846 +0x697
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).RTPDemuxer(0xc000376200, 0xc020a00be8, 0xc03cc5c304, 0x600, 0x600, 0x600)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:693 +0x19c8
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).startStream(0xc000376200)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:308 +0x678
created by github.com/deepch/vdk/format/rtspv2.Dial
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:237 +0x7fd
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

In the picture-glance card the error says:

Failed to start WebRTC stream: RTSPtoWeb server communication failure: Cannot connect to host 127.0.0.1:8083 ssl:default [Connect call failed ('127.0.0.1', 8083)]

A suspicion I have is that by SSL config is likely messed up as I can't find help / instructions on how it should be setup for my use case. However, if that were the case, then wouldn't the issue affect all my cameras?

The picture-glance card YAML for the doorbell is:

type: picture-glance
title: Front Door
entities:
  - entity: input_boolean.doorbell_camera_privacy
  - entity: camera.192_168_1_1
  - entity: binary_sensor.doorbell_occupancy
  - entity: binary_sensor.doorbell_motion
camera_image: camera.192_168_1_1
aspect_ratio: '4:3'
camera_view: live
state_filter:
  'on': brightness(40%) blur(10px) saturate(0.0)
  'off': brightness(100%)
entity: input_boolean.doorbell_camera_privacy

and for the driveway camera that is not working:

type: picture-glance
title: Driveway - East
entities:
  - entity: input_boolean.driveway_east_camera_privacy
  - entity: camera.driveway_east_camera
camera_image: camera.driveway_east_camera
aspect_ratio: '16:9'
camera_view: auto
state_filter:
  'on': brightness(40%) blur(10px) saturate(0.0)
  'off': brightness(100%)
entity: input_boolean.driveway_east_camera_privacy

I set the doorbell to camera_view: live and all the rest to camera_view: auto as webRTC was causing my Home Assistant to be sluggish due to high resource usage even though the system is running on an i7-8700T based tinyPC with plenty of RAM and SSD space.

If I start RTSPtoWeb - WebRTC (version: 1.2.2) up again then it all works until it stops again randomly. Even when it appears to be working, I have tons of this same error in the logs:

time="2022-08-15T09:36:34-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart

Edit: I just tested setting the 5 camera views on my main dashboard to live and the CPU usage for webRTC is pinned at 130%! Not sure how it can go over 100% anyhow... it is way more than the normal ~20%. I then realized I had 2 tabs open... once I closed one, the CPU usage went down to 50-60%... still high.

alexruffell commented 2 years ago

IT happened again, not sure whether it is the exact same error so posting this one too:

time="2022-08-15T13:38:11-05:00" level=error msg="Stream error restart stream stream no video" call=Restart
time="2022-08-15T13:38:11-05:00" level=error msg="Stream error restart stream stream no video" call=Restart
time="2022-08-15T13:38:12-05:00" level=error msg="Stream error restart stream Camera send statusRTSP/1.0 404 Not Found" call=Restart
panic: runtime error: index out of range [2] with length 2
goroutine 7937 [running]:
github.com/deepch/vdk/codec/h264parser.NewCodecDataFromSPSAndPPS(0xc01d384013, 0x2, 0x583, 0xc067803210, 0x592, 0x592, 0x0, 0x0, 0x0, 0x0, ...)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/codec/h264parser/parser.go:704 +0x410
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).CodecUpdateSPS(0xc000660c00, 0xc01d384013, 0x2, 0x583)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:846 +0x697
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).RTPDemuxer(0xc000660c00, 0xc000495158, 0xc01d384004, 0x592, 0x592, 0x592)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:693 +0x19c8
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).startStream(0xc000660c00)
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:308 +0x678
created by github.com/deepch/vdk/format/rtspv2.Dial
    /root/go/pkg/mod/github.com/deepch/vdk@v0.0.0-20220317152139-68ae487ae8a6/format/rtspv2/client.go:237 +0x7fd
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
AlexxIT commented 2 years ago

You don't using this component. You using https://www.home-assistant.io/integrations/rtsp_to_webrtc/