为什么我在将文件上传到网速较慢的服务器时收到 ERR_HTTP2_PING_FAILED?

Val*_*avi 6 django file-upload nginx gunicorn angular

我使用 Angular 应用程序作为前端,使用 Django Rest 框架作为后端服务,使用 Gunicorn 应用程序服务器与我的应用程序交互,使用 Nginx 反向代理到 Gunicorn 的安全和性能功能,为我的应用程序提供服务。

有一个将文件上传到服务器的请求,当文件很大(大约 100mb)且互联网速度很慢时,该请求会失败,而小文件(小于 10mb)则一切正常。

这是我收到的错误

net::ERR_TIMED_OUT
net::ERR_HTTP2_PING_FAILED
net::ERR_CONNECTION_RESET
Run Code Online (Sandbox Code Playgroud)

这是我的 Nginx 配置:

location ~ ^(/upload_video/[^/]+) {
    keepalive_timeout 128;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    client_max_body_size 100M;
    proxy_pass http://unix:/run/gunicorn.sock;
}
Run Code Online (Sandbox Code Playgroud)

这是我的 Gunicorn 服务:

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/rest_api
ExecStart=/home/ubuntu/hediehchi_rest_api/myenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
      --timeout 180 \
          --bind unix:/run/gunicorn.sock \
          webapp.wsgi:application

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

有什么问题?如果需要添加任何信息,请在下面评论。

小智 3

如果你想上传100MB,你需要一个client_max_body_size更大的。其次,您要寻找的超时是client_body_timeout