home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.67k stars 30.8k forks source link

Synology DSM: unable to view camera stream #43266

Closed rigrig closed 3 years ago

rigrig commented 4 years ago

The problem

Viewing a camera stream through Synology Surveillance Station doesn't work: Camera: Foscam C1 at 192.168.2.15
Surveillance station: 192.168.2.8
Home Assistant: 192.168.2.8 (docker on the same NAS)

From the log it seems like it is trying to connect to 192.168.2.99, but I know there aren't any devices with that address in my network.

Environment

Problem-relevant configuration.yaml

none: integration is configured through UI, core.config.entries section:

 {
                "entry_id": "8f42a5587148a7bfe773689d8ea7a4c7",
                "version": 1,
                "domain": "synology_dsm",
                "title": "localhost",
                "data": {
                    "host": "localhost",
                    "port": 5001,
                    "ssl": true,
                    "username": "hass",
                    "password": "*****",
                    "mac": [
                        "00-11-32-62-D8-14",
                        "00-11-32-62-D8-13"
                    ]
                },
                "options": {},
                "system_options": {
                    "disable_new_entities": false
                },
                "source": "user",
                "connection_class": "cloud_poll",
                "unique_id": "1680NZN188002"
            },

Traceback/Error logs

(passwords replaced with *****)

2020-11-15 18:55:52 ERROR (stream_worker) [libav.tcp] Connection to tcp://192.168.2.99:554?timeout=5000000 failed: Host is unreachable
2020-11-15 18:55:52 ERROR (stream_worker) [homeassistant.components.stream.worker] Stream connection failed: rtsp://syno:*****@192.168.2.99:554/Sms=2.unicast
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 54, in stream_worker
    _stream_worker_internal(hass, stream, quit_event)
  File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 71, in _stream_worker_internal
    container = av.open(stream.source, options=stream.options, timeout=STREAM_TIMEOUT)
  File "av/container/core.pyx", line 354, in av.container.core.open
  File "av/container/core.pyx", line 225, in av.container.core.Container.__cinit__
  File "av/container/core.pyx", line 257, in av.container.core.Container.err_check
  File "av/error.pyx", line 336, in av.error.err_check
av.error.OSError: [Errno 113] Host is unreachable: 'rtsp://syno:*****@192.168.2.99:554/Sms=2.unicast'; last error log: [tcp] Connection to tcp://192.168.2.99:554?timeout=5000000 failed: Host is unreachable

Additional information

probot-home-assistant[bot] commented 4 years ago

synology_dsm documentation synology_dsm source (message by IssueLinks)

SiliconAvatar commented 3 years ago

I'm having the same issue on my end.

I can (very temporary) resolve this by going to the Synology DSM integration and clicking "Reload". The cameras work again after that, but stop working again shortly afterward.

denilsonsa commented 3 years ago

Same behavior as @SiliconAvatar here. It can correctly detect the camera from Synology, it can show still images from the camera (updating every few seconds), but clicking on the camera card on the interface plays no video. Logs show:

2021-01-09 11:37:48 ERROR (stream_worker) [libav.rtsp] method DESCRIBE failed: 401 Unauthorized
2021-01-09 11:37:48 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream rtsp://syno:****@192.168.***.***:554/Sms=4.unicast

The IP address is correct, which makes me believe my issue (and possibly @SiliconAvatar's issue as well) has a different root cause than @rigrig's issue (expired credentials, instead of wrong host).

Home Assistant 2020.12.2 running on HA OS 5.10, on a RPi3.

Like @SiliconAvatar, going to /config/integrations and clicking on "⋮ → Reload" on the Synology DSM integration will "work": the live video stream from the camera will be playable inside Home Assistant, but after a while (hours? minutes? I haven't measured.) it will start failing again.

EDIT: Seems like my issue is better described at #43080 and #44573 and #43683.

mib1185 commented 3 years ago

Hi all,

based on #43683 f469caf I have created new docker images containing improvements for camera data update. They can be found here https://hub.docker.com/r/mib85/homeassistant

It would be great, if some of you could test it on your environment.

thanks in advanced.

rigrig commented 3 years ago

I gave it a try, didn't solve my issue :-(

mib1185 commented 3 years ago

Hi @rigrig thanks for testing. Because the synology_dsm integration takes over the life view URL (rtsp://syno:*****@192.168.2.99:554/Sms=2.unicast in your case) directly from surveillance station, please check the Path and if available URL data directly from camera configuration in surveillance station (example below) image

rigrig commented 3 years ago

Hrm... Turns out that I didn't pay attention, and 192.168.2.99 actually is in use, by the second network interface. And apparently Synology advertises that as public ip.
My camera settings look like this:
image

So I have these ip addresses:
192.168.2.1: router 192.168.2.8: DSM (home assistant also runs here, inside docker) 192.168.2.99: DSM (secondary interface) 192.168.2.15: Camera

Reason for this is that my router ran out of ports, so I set it up so that I could connect another device through the secondary NAS port, forgot I assigned .99 to it :-| I definitely configured the integration with 192.168.2.8 though, so no idea why it tried to connect to 192.168.2.99, probably Surveillance Station getting confused?

And even weirder: I just removed the integration, restarted HA, added it again, and now it does work properly...

mib1185 commented 3 years ago

Nice to know, that you found the root cause for the issue in your setup 👍 If your issue is solved, please close this one.

Btw. configure IP address from same subnet on two different interfaces in same routing context is not a good idea 😉 If you need more ethernet ports in your network, than I would highly recommend to invest in a switch (already available for less than 20€ - for an unmanaged switch example is TP-Link TL-SG105)

rigrig commented 3 years ago

Whoops, sorry for not closing this.
And thanks for the advice. I know it's not great, but as long as it works I'm happy to avoid adding yet another box to my mess ;-)