Question

UWSGI made response but NGINX return empty response.

My other api endpoints are working fine but only a file upload specific api endpoint is not working.

i’m using Flask for API development, along with nginx and uwsgi.

UWSGI LOG

[pid: 107416|app: 0|req: 1/2] 106.78.35.202 () {44 vars in 886 bytes} [Tue Mar  2 05:54:26 2021] POST /api/file_upload => generated 296 bytes in 5876 msecs (HTTP/1.1 200) 3 headers in 104 bytes (4 switches on core 0)

NGINX LOG

2021/03/02 05:59:32 [error] 107686#107686: *2 upstream timed out (110: Connection timed out) while reading upstream, client: ***.**.**.***, server: ***.***.**.***, request: "POST /api/file_upload HTTP/1.1", upstream: "uwsgi://unix:/var/www/vocal/vocal.sock:", host: "***.***.**.***"

Nginx config file.

server {
	
	listen 80;
	server_name ***.***.**.***;

	root /var/www/vocal/;
	access_log              /var/log/nginx/vocal_access.log;
	error_log               /var/log/nginx/vocal_error_log;

	uwsgi_read_timeout      300s;
	uwsgi_send_timeout      300s;
	proxy_read_timeout 	300s;


    location / {

        include 		uwsgi_params;
        uwsgi_pass 		unix:/var/www/vocal/vocal.sock;		

	client_max_body_size    15M;
       # proxy_pass		unix:/var/www/vocal/vocal.sock;
	proxy_redirect     	off;
        proxy_set_header   	Host $host;
        proxy_set_header  	X-Real-IP $remote_addr;
        proxy_set_header   	X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   	X-Forwarded-Host $server_name;
	proxy_read_timeout 	300;
    }

    location /output {
        autoindex on;
        alias 			/var/www/vocal/output/;
	sendfile           	on;
	#sendfile_max_chunk 	15m;
	proxy_read_timeout      300;
    }

    location /upload {
        autoindex on;
        alias 			/var/www/vocal/app/main/file_upload/upload/;
	sendfile           	on;
        #sendfile_max_chunk 	15m;
	proxy_read_timeout      300;
    }

}

uwsgi file config.

[uwsgi]
module = wsgi:application

master = true
processes = 10

socket = vocal.sock
#socket = 127.0.0.1:5000
chmod-socket = 660
vacuum = true

die-on-term = true

logto = /var/log/uwsgi/%n.log

#protocol = uwsgi
harakiri = 120
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

As far as I can see the backend service is handling the request for around 6 seconds or so, however, the proxy_read_timeout inside your location / is set to 300 without an s at the end which I believe defaults to milliseconds.

I could suggest either changing it to 3600 for example or adding an s: 300s.

Let me know how it goes! Regards, Bobby