inference fixes

This commit is contained in:
Dobromir Popov
2026-07-09 20:46:29 +02:00
parent 2b000ce9c3
commit 3d264a500a
6 changed files with 120 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ from __future__ import annotations
import asyncio
import json
import logging
import os
import threading
import uuid
from pathlib import Path
@@ -23,6 +24,22 @@ from .peer_registry import PeerRegistry
log = logging.getLogger(__name__)
# Activation tensors ride the relay as base64 inside one JSON frame, so the
# websockets default of 1 MiB rejects any real prefill (close code 1009).
DEFAULT_WS_MAX_BYTES = 256 * 1024 * 1024
def ws_max_size() -> int | None:
"""Max inbound WebSocket frame size; MESHNET_WS_MAX_BYTES<=0 means unlimited."""
raw = os.environ.get("MESHNET_WS_MAX_BYTES", "").strip()
if not raw:
return DEFAULT_WS_MAX_BYTES
try:
value = int(raw)
except ValueError:
return DEFAULT_WS_MAX_BYTES
return None if value <= 0 else value
class RelayServer:
"""Async WebSocket relay server that runs in a background thread.
@@ -100,6 +117,7 @@ class RelayServer:
self.host,
self.port,
ssl=ssl_ctx,
max_size=ws_max_size(),
)
# Record actual port after bind
for sock in server.sockets or []: