Uwsgi + nginx + bulb: upstream closed prematurely

I created an endpoint on my flask that generates a spreadsheet from a database query (remote db) and then sends it as a download in a browser. The flask does not cause any errors. Uwsgi is not complaining.

But when I check nginx error.log, I see a lot

2014/12/10 05:06:24 [error] 14084 # 0: * 239436 upstream prematurely closed connection while reading the response header up, client: 34.34.34.34, server: me.com, request: "GET / download / export.csv HTTP / 1.1 ", upstream:" uwsgi: //0.0.0.0: 5002 ", host:" me.com ", referrer:" https://me.com/download/export.csv "

I am using uwsgi for example

uwsgi --socket 0.0.0.0:5002 --buffer-size=32768 --module server --callab app

my nginx config:

server {
     listen 80;
     merge_slashes off;
     server_name me.com www.me.cpm;

     location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
     }

}

server {
      listen 443;
      merge_slashes off;
      server_name me.com www.me.com;

    location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
       }
}

Is this a nginx or uwsgi problem, or both?

+4
6

nginx.conf,

sendfile        on;
client_max_body_size 20M;
keepalive_timeout  0;

. uwsgi upstart amazon linux

+5

uwsgi_pass 0.0.0.0:5002; uwsgi_pass 127.0.0.1:5002; unix.

+1

, . , uwsgi_pass, , proxy_pass, http-timeout uWSGI ( ).

0

, uwsgi socket-timeout = 65 ( uwsgi.ini) --socket-timeout=65 (uwsgi command line). , -. socket-timeout = 65 uwsgi.ini .

0

Docker WSGI Elastic Beanstalk. EC2 :

upstream docker {
    server 172.17.0.3:8080;
    keepalive 256;
}

, :

siege -b -c 16 -t 60S -T 'application/json' 'http://host/foo POST {"foo": "bar"}'

... EC2 ~ 70%. 502 , .

, keepalive , , - HTTP keep-alive uWSGI, --http-keepalive ( 1.9).

0

, nginx uwsgi, uwsgi http-. nginx uwsgi, uwsgi uwsgi.

0

All Articles