From 8256acb8efb3f32ff302f4766a85a6830f306cd5 Mon Sep 17 00:00:00 2001 From: olijouve <17448560+olijouve@users.noreply.github.com> Date: Thu, 4 Feb 2021 09:25:35 +0100 Subject: [PATCH] Fix onvif ConnectionResetError (#45899) Fix "ConnectionResetError: Cannot write to closing transport" error we can have on lots of chinese cams(like Goke GK7102 based IP cameras) Those non full onvif compliant cams can "crash" when calling non implemented functions like events or ptz and they are likely react by closing transport, leaving the request in a uncatched error state. My camera used to fail on setup, and now it run nicely with that simple fix. --- homeassistant/components/onvif/device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/onvif/device.py b/homeassistant/components/onvif/device.py index 84761a4777f..c0851cbe32f 100644 --- a/homeassistant/components/onvif/device.py +++ b/homeassistant/components/onvif/device.py @@ -250,14 +250,14 @@ class ONVIFDevice: pullpoint = False try: pullpoint = await self.events.async_start() - except (ONVIFError, Fault): + except (ONVIFError, Fault, RequestError): pass ptz = False try: self.device.get_definition("ptz") ptz = True - except ONVIFError: + except (ONVIFError, Fault, RequestError): pass return Capabilities(snapshot, pullpoint, ptz)