【问题标题】:HTTP request 408 error(Client request timeout) over mobile network. Django + Gunicorn + Nginx移动网络上的 HTTP 请求 408 错误(客户端请求超时)。 Django + Gunicorn + Nginx
【发布时间】:2017-11-21 22:56:45
【问题描述】:

我遇到了奇怪的问题。我的 API 有一个端点,我正在使用 PATCH(也尝试 PUT 和 POST - 结果相同)从手机发送带有 jsonarray 的 json(请求正文大小通常为 40KB)。当我使用 Wi-Fi 执行此操作时 - 一切正常。但是,如果我使用移动网络,我会在某些手机上遇到 SocketConnection Timeout(在 Retrofit/Kotlin 中)(iOS 运行良好)。

来自 nginx access.log:

domain - - [21/Nov/2017:16:33:01 +0000] "PATCH /endpoint/ HTTP/1.1" 408 0 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 5 Build/M4B30Z)"

Nginx 配置:

server {
    listen port;
    server_name domain;
    client_max_body_size 32m;
    proxy_connect_timeout 75s;
    proxy_read_timeout 300s;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
      root /home/user/apps/api;
    }


     location / {
     include proxy_params;
     proxy_pass http://unix:/home/user/apps/api/api.sock;
}

    listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

Gunicorn 配置:

respawn
setuid root
setgid www-data
chdir /home/user/apps/api

exec /home/user/virtualenvs/apienv/bin/gunicorn --workers 3 --timeout=90 --bind unix://api.sock api.wsgi:application

【问题讨论】:

    标签: django http nginx gunicorn


    【解决方案1】:

    问题出在网络连接上。我们将云的位置从法兰克福更改为阿姆斯特丹,现在一切正常

    【讨论】:

      猜你喜欢
      • 2014-08-16
      • 1970-01-01
      • 2010-12-12
      • 2015-03-31
      • 2019-10-29
      • 1970-01-01
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多