From bd035f8c17c65165dcd241d4f11bf7542a170d84 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 26 Mar 2026 14:05:22 -0400 Subject: [PATCH] fix(nginx,gunicorn): raise send_timeout and proxy_send_timeout for long-running endpoints Nginx was closing the client connection after exactly 60 seconds on requests like clip_video (ffmpeg, 5-40 min) because send_timeout and proxy_send_timeout both default to 60s. proxy_read_timeout was already 2100s but the other two timeouts were still at defaults. With proxy_buffering off, Nginx holds the write path to the client open as soon as the upstream connection is established. If the upstream sends no data for 60s (e.g. ffmpeg processing), Nginx treats the idle write path as stalled and closes the client connection, logging 499 (Client Closed Request). Fixed: raise proxy_send_timeout and send_timeout to 2100s to match proxy_read_timeout in the main location block. Also raised the Gunicorn default timeout from 30s to 120s in gunicorn_conf.py as a belt-and-suspenders measure (AE_API_GUNICORN_TIMEOUT env var takes precedence). Co-Authored-By: Claude Sonnet 4.6 --- conf/aether_fastapi_gunicorn_conf.py | 2 +- conf/nginx/site-enabled_aether_fastapi_gunicorn.conf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/conf/aether_fastapi_gunicorn_conf.py b/conf/aether_fastapi_gunicorn_conf.py index 9992672..0cb6df5 100644 --- a/conf/aether_fastapi_gunicorn_conf.py +++ b/conf/aether_fastapi_gunicorn_conf.py @@ -16,7 +16,7 @@ chdir = "/srv/aether_api" wsgi_app = "app.main:app" # Numeric variables must be integers -timeout = int(os.getenv('AE_API_GUNICORN_TIMEOUT', 30)) +timeout = int(os.getenv('AE_API_GUNICORN_TIMEOUT', 120)) graceful_timeout = int(os.getenv('AE_API_GUNICORN_GRACEFUL_TIMEOUT', 30)) keepalive = int(os.getenv('AE_API_GUNICORN_KEEPALIVE', 4)) diff --git a/conf/nginx/site-enabled_aether_fastapi_gunicorn.conf b/conf/nginx/site-enabled_aether_fastapi_gunicorn.conf index 4031f58..9f855c0 100644 --- a/conf/nginx/site-enabled_aether_fastapi_gunicorn.conf +++ b/conf/nginx/site-enabled_aether_fastapi_gunicorn.conf @@ -50,6 +50,10 @@ server { # proxy read timeout being too low will cause 504 Gateway Time-out on the client browser proxy_read_timeout 2100s; + # proxy_send_timeout and send_timeout default to 60s. For long-running endpoints + # (clip_video, ffmpeg operations that take 5-40 min), raise to match proxy_read_timeout. + proxy_send_timeout 2100s; + send_timeout 2100s; proxy_pass http://fastapi_backend; }