core: Invalid ONVIF SubscriptionManager RenewRequest - python-zeep WSA bug

The problem

The problem is missing addressing in the SubscriptionManager/RenewRequest. The Header contains only the Security element. Action, To and MessageID are missing in the Header of the Renew request. As the result a lot of ONVIF cameras (XiongMai, Wanscam and other) response 400 (Bad Request) to RenewRequest. It is impossible to add/setup these cameras at all. You can see different errors in logs, but the reason is the same. My patch to python-zeep which fixed this issue was reverted. So it must be fixed in Home Assistant code.

Environment

  • Home Assistant Core release with the issue: 2021.1.5
  • Last working Home Assistant Core release (if known): never
  • Operating environment (OS/Container/Supervised/Core): Supervised
  • Integration causing this issue: ONVIF
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/onvif

Problem-relevant configuration.yaml

logger:
  default: info
  logs:
    homeassistant.components.onvif: debug

Traceback/Error logs

2021-01-25 03:57:41 DEBUG (MainThread) [homeassistant.components.onvif] Setting up the ONVIF device management service
2021-01-25 03:57:41 DEBUG (MainThread) [homeassistant.components.onvif] Retrieving current device date/time
2021-01-25 03:57:41 DEBUG (MainThread) [homeassistant.components.onvif] Device date/time: 2021-01-24 23:57:42+00:00 | System date/time: 2021-01-24 23:57:41.482773+00:00
2021-01-25 03:57:44 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Cam1 - xx:xx:xx:xx:xx:xx for onvif
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 77, in async_setup_entry
    if not await device.async_setup():
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 105, in async_setup
    self.capabilities = await self.async_get_capabilities()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 252, in async_get_capabilities
    pullpoint = await self.events.async_start()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 83, in async_start
    await self.async_renew()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 154, in async_renew
    await self._subscription.Renew(termination_time)
  File "/usr/local/lib/python3.8/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
    return self.process_error(doc, operation)
  File "/usr/local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 381, in process_error
    subcode_qname = as_qname(
  File "/usr/local/lib/python3.8/site-packages/zeep/utils.py", line 36, in as_qname
    raise XMLParseError("No namespace defined for %r (%r)" % (prefix, value))
zeep.exceptions.XMLParseError: No namespace defined for 'ter' ('ter:InvalidArgVal')

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 34 (14 by maintainers)

Commits related to this issue

Most upvoted comments

This patch must fix the issue mvantellingen/python-zeep#1206

Zeep 4.1.0 has been released yesterday. This patch was merged and reverted immediately with the following comment:

Just reverted it again, needs more thinking (if you always want WSA you could just list it in the plugins)

It means that this issue must be fixed in ONVIF integration which is a part of Home Assistant Core.

@slydiman is this issue now patched in an upcoming release?

https://github.com/slydiman/ha_custom_onvif Any comments/improvements are welcome.

https://github.com/home-assistant/core/pull/42651/files

solved this with editing and reverting back the code