502 Bad Gateway when running Stock Quantity Issues wizard

Hi,

When launching long time process such “Generate Stock Quantity Issues” wizard, I get “502 Bad Gateway” error after some time. (Nginx error log: “upstream prematurely closed connection while reading response header from upstream”)

My server is launched with gunicorn behind nginx.

Here’s my nginx configuration:

server {
    listen 8000;
    server_name trytond-server;
    client_max_body_size 100M;

    location / {
        proxy_pass http://unix:/srv/tryton/7.2/trytond.sock;
        proxy_read_timeout 600s;
        proxy_connect_timeout 75s;
    }
}

and my gunicorn configuration:

wsgi_app = 'trytond.application:app'
bind = 'unix:/srv/tryton/7.2/trytond.sock'
workers = 5
worker_class = 'gevent'
worker_connections = 1000
timeout = 600
raw_env = [
        'TRYTOND_CONFIG=/srv/tryton/7.2/trytond.conf',
        'TRYTOND_DATABASE_NAMES = tryton_preciball_prod_72',
        'TRYTOND_LOGGING_CONFIG=/srv/tryton/7.2/trytond_log.conf',
]
PYTHONOPTIMIZE = 1

Any advice to avoid such error ? Thanks. :slight_smile:

You probably need to increase the proxy_read_timeout.
I wrote Retries on gateway timeout (#13222) · Issues · Tryton / Tryton · GitLab to make it work transparently.

1 Like

It’s working now :slight_smile:

I forgot to restart gunicorn after my changes.

My configuration files in the initial post are correct.
So, I’ve increased gunicorn timeout from 90 to 600 and added proxy_read_timeout and proxy_connect_timeout to nginx configuration to avoid 502 error.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.