increase max ws response size for instances with large agent counts

This commit is contained in:
wh1te909 2024-02-25 02:18:40 +00:00
parent 03c087020c
commit 6ae56ac2cc
5 changed files with 10 additions and 4 deletions

View File

@ -5,13 +5,14 @@ import websockets
from django.core.management.base import BaseCommand
from core.utils import get_mesh_ws_url
from tacticalrmm.constants import WS_MAX_SIZE
class Command(BaseCommand):
help = "Sets up initial mesh central configuration"
async def websocket_call(self, uri):
async with websockets.connect(uri) as websocket:
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as websocket:
# Get Invitation Link
await websocket.send(
json.dumps(

View File

@ -6,13 +6,14 @@ from django.conf import settings
from django.core.management.base import BaseCommand
from core.utils import get_core_settings, get_mesh_ws_url
from tacticalrmm.constants import WS_MAX_SIZE
class Command(BaseCommand):
help = "Sets up initial mesh central configuration"
async def websocket_call(self, uri):
async with websockets.connect(uri) as websocket:
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as websocket:
# Get Device groups to see if it exists
await websocket.send(json.dumps({"action": "meshes"}))

View File

@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any
import websockets
from accounts.utils import is_superuser
from tacticalrmm.constants import WS_MAX_SIZE
from tacticalrmm.helpers import make_random_password
from tacticalrmm.logger import logger
@ -34,7 +35,7 @@ def mesh_action(
*, payload: dict[str, Any], uri: str, wait=True
) -> dict[str, Any] | None:
async def _do(payload, uri: str):
async with websockets.connect(uri) as ws:
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as ws:
await ws.send(json.dumps(payload))
if wait:
async for message in ws:

View File

@ -16,6 +16,7 @@ from tacticalrmm.constants import (
AGENT_TBL_PEND_ACTION_CNT_CACHE_PREFIX,
CORESETTINGS_CACHE_KEY,
ROLE_CACHE_PREFIX,
WS_MAX_SIZE,
AgentPlat,
MeshAgentIdent,
)
@ -99,7 +100,7 @@ def get_mesh_ws_url() -> str:
async def get_mesh_device_id(uri: str, device_group: str) -> None:
async with websockets.connect(uri) as ws:
async with websockets.connect(uri, max_size=WS_MAX_SIZE) as ws:
payload = {"action": "meshes", "responseid": "meshctrl"}
await ws.send(json.dumps(payload))

View File

@ -32,6 +32,8 @@ AGENT_OUTAGES_LOCK = "agent-outages-task-lock-key"
ORPHANED_WIN_TASK_LOCK = "orphaned-win-task-lock-key"
SYNC_MESH_PERMS_TASK_LOCK = "sync-mesh-perms-lock-key"
WS_MAX_SIZE = 100 * 2**20
class GoArch(models.TextChoices):
AMD64 = "amd64", "amd64"