lucas63 lucas63 - 3 months ago 56
HTTP Question

HTTP request 408 error(Client request timeout) over mobile network. Django + Gunicorn + Nginx

I have faced with strange issue. My API has endpoint on which i am using PATCH(tried also PUT and POST - same result) to send json with jsonarray(request body size typically is 40KB) from mobile phone. When i am doing this using Wi-Fi - all works fine. But if i am using mobile network, i am facing with SocketConnection Timeout(in Retrofit/Kotlin) with some phones(iOS works perfect).

From 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 config :

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/; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

Gunicorn config :

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

Answer Source

The problem was in network connection. We changed location of our clouds from Frankfurt to Amsterdam and now all works perfect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download