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.48k stars 30.7k forks source link

7 live camera crash #49477

Closed Damix48 closed 3 years ago

Damix48 commented 3 years ago

The problem

When I add 7+ cameras (live in lovelance) HA freeze and crash.

When I add 6 live camera no problem, but when I add the 7th (in the same view or spread in different views) HA freeze and "crash". I got an error only 1 time.

What is version of Home Assistant Core has the issue?

core-2021.4.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Camera

Link to integration documentation on our website

No response

Example YAML snippet

configuration.yaml:

camera:
  - platform: generic
    name: Cassa Negozio
    still_image_url: rtsp://admin:password@192.168.178.22/live1.sdp
    stream_source: rtsp://admin:password@192.168.178.22/live1.sdp

  - platform: mjpeg
    name: Entrata Nonni
    mjpeg_url: http://admin:password@192.168.178.23/video/mjpg.cgi

  - platform: mjpeg
    name: Quadro elettrico negozio
    mjpeg_url: http://admin:password@192.168.178.24/video/mjpg.cgi

  - platform: mjpeg
    name: Porticato Nonni
    mjpeg_url: http://admin:password@192.168.178.25/video/mjpg.cgi

  - platform: mjpeg
    name: Ufficio
    mjpeg_url: http://admin:password@192.168.178.27/video/mjpg.cgi

  - platform: mjpeg
    name: Condizionatore
    mjpeg_url: http://admin:password@192.168.178.28/video/mjpg.cgi

  - platform: mjpeg
    name: Magazzino
    mjpeg_url: http://admin:password@192.168.178.29/video.cgi

  - platform: mjpeg
    name: Casa Nord
    mjpeg_url: http://admin:password@192.168.178.30/video/mjpg.cgi

  - platform: mjpeg
    name: Casa Cancelli
    mjpeg_url: http://admin:password@192.168.178.31/video/mjpg.cgi

Anything in the logs that might be useful for us?

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
return await handler(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
return await handler(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/http/ban.py", line 74, in ban_middleware
return await handler(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/http/auth.py", line 135, in auth_middleware
return await handler(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/http/view.py", line 131, in handle
result = await result
File "/usr/lib/python3.8/site-packages/homeassistant/components/camera/__init__.py", line 498, in get
return await self.handle(request, camera)
File "/usr/lib/python3.8/site-packages/homeassistant/components/camera/__init__.py", line 533, in handle
return await camera.handle_async_mjpeg_stream(request)
File "/usr/lib/python3.8/site-packages/homeassistant/components/mjpeg/camera.py", line 163, in handle_async_mjpeg_stream
return await async_aiohttp_proxy_web(self.hass, request, stream_coro)
File "/usr/lib/python3.8/site-packages/homeassistant/helpers/aiohttp_client.py", line 110, in async_aiohttp_proxy_web
return await async_aiohttp_proxy_stream(
File "/usr/lib/python3.8/site-packages/homeassistant/helpers/aiohttp_client.py", line 140, in async_aiohttp_proxy_stream
await response.write(data)
File "/usr/lib/python3.8/site-packages/aiohttp/web_response.py", line 470, in write
await self._payload_writer.write(data)
File "/usr/lib/python3.8/site-packages/aiohttp/http_writer.py", line 107, in write
self._write(chunk)
File "/usr/lib/python3.8/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transporte[0m

Additional information

No response

uvjustin commented 3 years ago

Most browsers are limited to 6 simultaneous TCP connections to a given domain when using http/1.1. See https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser You might be able to increase this if you use a reverse proxy that supports http/2 such as NGINX. Note that MJPEG streams can be fairly network intensive so this may also present issues, especially over wifi.

Damix48 commented 3 years ago

Thank you!