Spaces:
Sleeping
Sleeping
increase max size for websocket
Browse files- viser_proxy_manager.py +8 -2
viser_proxy_manager.py
CHANGED
|
@@ -19,6 +19,7 @@ class ViserProxyManager:
|
|
| 19 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
| 20 |
max_local_port: Maximum local port number to use for Viser servers. Defaults to 9000.
|
| 21 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
|
|
|
| 22 |
"""
|
| 23 |
|
| 24 |
def __init__(
|
|
@@ -26,9 +27,11 @@ class ViserProxyManager:
|
|
| 26 |
app: FastAPI,
|
| 27 |
min_local_port: int = 8000,
|
| 28 |
max_local_port: int = 9000,
|
|
|
|
| 29 |
) -> None:
|
| 30 |
self._min_port = min_local_port
|
| 31 |
self._max_port = max_local_port
|
|
|
|
| 32 |
self._server_from_session_hash: dict[str, viser.ViserServer] = {}
|
| 33 |
self._last_port = self._min_port - 1 # Track last port tried
|
| 34 |
|
|
@@ -95,8 +98,11 @@ class ViserProxyManager:
|
|
| 95 |
return
|
| 96 |
|
| 97 |
try:
|
| 98 |
-
# Connect to the target WebSocket
|
| 99 |
-
async with websockets.connect(
|
|
|
|
|
|
|
|
|
|
| 100 |
# Create tasks for bidirectional communication
|
| 101 |
async def forward_to_target():
|
| 102 |
"""Forward messages from the client to the target WebSocket."""
|
|
|
|
| 19 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
| 20 |
max_local_port: Maximum local port number to use for Viser servers. Defaults to 9000.
|
| 21 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
| 22 |
+
max_message_size: Maximum WebSocket message size in bytes. Defaults to 100MB.
|
| 23 |
"""
|
| 24 |
|
| 25 |
def __init__(
|
|
|
|
| 27 |
app: FastAPI,
|
| 28 |
min_local_port: int = 8000,
|
| 29 |
max_local_port: int = 9000,
|
| 30 |
+
max_message_size: int = 100 * 1024 * 1024, # 100MB default
|
| 31 |
) -> None:
|
| 32 |
self._min_port = min_local_port
|
| 33 |
self._max_port = max_local_port
|
| 34 |
+
self._max_message_size = max_message_size
|
| 35 |
self._server_from_session_hash: dict[str, viser.ViserServer] = {}
|
| 36 |
self._last_port = self._min_port - 1 # Track last port tried
|
| 37 |
|
|
|
|
| 98 |
return
|
| 99 |
|
| 100 |
try:
|
| 101 |
+
# Connect to the target WebSocket with increased message size
|
| 102 |
+
async with websockets.connect(
|
| 103 |
+
target_ws_url,
|
| 104 |
+
max_size=self._max_message_size, # Set max message size for receiving
|
| 105 |
+
) as ws_target:
|
| 106 |
# Create tasks for bidirectional communication
|
| 107 |
async def forward_to_target():
|
| 108 |
"""Forward messages from the client to the target WebSocket."""
|