Increase core websocket proxy maximum message size to 64MiB (#4443)

This commit is contained in:
J. Nick Koston 2023-07-19 13:02:42 -05:00 committed by GitHub
parent f1a72ee418
commit f9bc2f5993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -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()