diff --git a/apps/demo/app.py b/apps/demo/app.py index 9d5bffb..e86ee41 100644 --- a/apps/demo/app.py +++ b/apps/demo/app.py @@ -23,7 +23,7 @@ async def index(request): async def ws_handler(request): if ROLE != "realtime": raise web.HTTPNotFound() - ws = web.WebSocketResponse(heartbeat=30) + ws = web.WebSocketResponse(heartbeat=30, max_msg_size=1024 * 1024) await ws.prepare(request) async for msg in ws: if msg.type == WSMsgType.TEXT: diff --git a/nginx/conf.d/edge.conf b/nginx/conf.d/edge.conf index b813d2d..de397f6 100644 --- a/nginx/conf.d/edge.conf +++ b/nginx/conf.d/edge.conf @@ -40,6 +40,8 @@ server { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 1h; + proxy_send_timeout 60s; + proxy_max_temp_file_size 0; proxy_pass http://realtime_pool; } @@ -54,7 +56,7 @@ server { listen 8081; server_name _; access_log off; - location = /health { return 200 'ok\n'; } + location = /health { default_type text/plain; return 200 'ok\n'; } location = /stub_status { stub_status; } location / { return 404; } } diff --git a/tests/test_project.py b/tests/test_project.py index d7add6d..2de5ec4 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -90,9 +90,16 @@ def test_metrics_port_isolation(self): edge_cfg = load('nginx/conf.d/edge.conf') self.assertIn('listen 8081;', edge_cfg) self.assertIn('location = /stub_status { stub_status; }', edge_cfg) - self.assertIn('location = /health { return 200 \'ok\\n\'; }', edge_cfg) + self.assertIn("location = /health { default_type text/plain; return 200 'ok\\n'; }", edge_cfg) self.assertIn('location / { return 404; }', edge_cfg) + def test_websocket_frame_and_proxy_buffering_bounds(self): + edge_cfg = load('nginx/conf.d/edge.conf') + self.assertIn('proxy_max_temp_file_size 0;', edge_cfg) + self.assertIn('proxy_send_timeout 60s;', edge_cfg) + source = load('apps/demo/app.py') + self.assertIn('max_msg_size=1024 * 1024', source) + def test_http_redirect_preserves_uri(self): edge_cfg = load('nginx/conf.d/edge.conf') self.assertIn('listen 80 default_server;', edge_cfg)