From f9bc2f59932dc0a983a099f6e1e31741f61715d6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 19 Jul 2023 13:02:42 -0500 Subject: [PATCH] Increase core websocket proxy maximum message size to 64MiB (#4443) --- supervisor/api/proxy.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/supervisor/api/proxy.py b/supervisor/api/proxy.py index 51f3f81b8..8f03e8af4 100644 --- a/supervisor/api/proxy.py +++ b/supervisor/api/proxy.py @@ -18,6 +18,13 @@ _LOGGER: logging.Logger = logging.getLogger(__name__) FORWARD_HEADERS = ("X-Speech-Content",) HEADER_HA_ACCESS = "X-Ha-Access" +# Maximum message size for websocket messages from Home Assistant. +# Since these are coming from core we want the largest possible size +# that is not likely to cause a memory problem as most modern browsers +# support large messages. +# https://github.com/home-assistant/supervisor/issues/4392 +MAX_MESSAGE_SIZE_FROM_CORE = 64 * 1024 * 1024 + class APIProxy(CoreSysAttributes): """API Proxy for Home Assistant.""" @@ -112,7 +119,9 @@ class APIProxy(CoreSysAttributes): url = f"{self.sys_homeassistant.api_url}/api/websocket" try: - client = await self.sys_websession.ws_connect(url, heartbeat=30, ssl=False) + client = await self.sys_websession.ws_connect( + url, heartbeat=30, ssl=False, max_msg_size=MAX_MESSAGE_SIZE_FROM_CORE + ) # Handle authentication data = await client.receive_json()