I’m trying to configure an ONVIF camera on my Hassio Raspberry device. The video stream has already been validated working with VLC.
My configuration is:
camera:
- platform: onvif
name: IP Cam ONVIF
host: 192.168.2.15
port: 8080
username: <REDACTED>
password: <REDACTED>
The logs show:
2019-03-24 04:32:33 INFO (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy_stream/camera.ip_cam_onvif to 206.71.228.130 (auth: False)
2019-03-24 04:32:37 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 98, in auth_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 112, in handle
result = await result
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/__init__.py", line 408, in get
return await self.handle(request, camera)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/__init__.py", line 444, in handle
return await camera.handle_async_mjpeg_stream(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/onvif.py", line 227, in handle_async_mjpeg_stream
await stream.close()
File "/usr/local/lib/python3.7/site-packages/haffmpeg/core.py", line 133, in close
await self._proc.communicate(input=b'q')
File "/usr/local/lib/python3.7/asyncio/subprocess.py", line 187, in communicate
loop=self._loop)
File "/usr/local/lib/python3.7/asyncio/subprocess.py", line 138, in _feed_stdin
self.stdin.write(input)
File "/usr/local/lib/python3.7/asyncio/streams.py", line 305, in write
self._transport.write(data)
File "uvloop/handles/stream.pyx", line 671, in uvloop.loop.UVStream.write
File "uvloop/handles/handle.pyx", line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <WriteUnixTransport closed=True reading=False 0x6d5d4030>; the handler is closed
2019-03-24 04:32:37 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start
await resp.prepare(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 353, in prepare
return await self._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 667, in _start
return await super()._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 410, in _start
await writer.write_headers(status_line, headers)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 112, in write_headers
self._write(buf)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
2019-03-24 04:33:31 INFO (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy_stream/camera.ip_cam_onvif to 206.71.228.130 (auth: False)
2019-03-24 04:33:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 98, in auth_middleware
return await handler(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 112, in handle
result = await result
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/__init__.py", line 408, in get
return await self.handle(request, camera)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/__init__.py", line 444, in handle
return await camera.handle_async_mjpeg_stream(request)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/camera/onvif.py", line 227, in handle_async_mjpeg_stream
await stream.close()
File "/usr/local/lib/python3.7/site-packages/haffmpeg/core.py", line 133, in close
await self._proc.communicate(input=b'q')
File "/usr/local/lib/python3.7/asyncio/subprocess.py", line 187, in communicate
loop=self._loop)
File "/usr/local/lib/python3.7/asyncio/subprocess.py", line 138, in _feed_stdin
self.stdin.write(input)
File "/usr/local/lib/python3.7/asyncio/streams.py", line 305, in write
self._transport.write(data)
File "uvloop/handles/stream.pyx", line 671, in uvloop.loop.UVStream.write
File "uvloop/handles/handle.pyx", line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <WriteUnixTransport closed=True reading=False 0x6de07ce0>; the handler is closed
2019-03-24 04:33:35 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start
await resp.prepare(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 353, in prepare
return await self._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 667, in _start
return await super()._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 410, in _start
await writer.write_headers(status_line, headers)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 112, in write_headers
self._write(buf)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
I’ve already tried enabling DEBUG
level logs but not much else is shown in the logs:
logger:
default: info
logs:
homeassistant.components.camera: debug
custom_components.camera.onvif: debug
homeassistant.components.camera.onvif: debug
What am I doing wrong or how can i further troubleshoot this issue?
Additionally, are there any clear advantages of having the camera configured using the ONVIF platform vs a regular MJPEG camera? Something I’m wishing it’d help me do is be able to control Pan/Tilt/Zoom while observing the stream, but i don’t know if that’s possible within Hassio’s UI/cards.
PS. As a workaround to get video I’ve set up a motion
daemon that reads the stream from the ONVIF camera and i connect to it via an mjpeg
stream on Hassio.