Tryton + Traefik get random bad gateway

Hi,

We have two tryton + docker installations. One with a traefik proxy and one with an apache proxy.
The second works perfectly. The first generates random “bad gateways”.
We tried different settings in traefik, labels and in uwsgi.conf but nothing changes, we always get random "bad gateway. This happens even after login.
Do you have an idea of the cause and what we could do to solve this problem?
thanks in advance.

1 Like

Maybe the proxy tries to open too much connections for the number of worker of µwsgi.

Have you tried setting the traefik maxIdleConnsPerHost to -1?

Hello
Thanks for your answers.
I tried both suggestions. But I get the same error message (bad gateway) after 3 clicks!

– Config uwsgi.conf

processes=2
threads=8
thunder-lock=true
vacuum=True
max-requests=5000
enable-threads = true
workers = 8
lazy-apps=true

– Logs

Starting uWSGI 2.0.19.1-debian (64bit) on [Thu May 11 10:09:24 2023]
compiled with version: 10.2.1 20210110 on 11 June 2021 09:08:33
os: Linux-5.10.0-14-cloud-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29)
nodename: 48061e1a0599
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /
detected binary path: /usr/bin/uwsgi-core
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to TCP address :8000 fd 3
Python version: 3.9.2 (default, Feb 28 2021, 17:03:44)  [GCC 10.2.1 20210110]
Python main interpreter initialized at 0x5595dab51e90
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1169920 bytes (1142 KB) for 64 cores
Operational MODE: preforking+threaded
uWSGI is running in multiple interpreter mode
spawned uWSGI worker 1 (pid: 1, cores: 8)
spawned uWSGI worker 2 (pid: 8, cores: 8)
spawned uWSGI worker 3 (pid: 9, cores: 8)
spawned uWSGI worker 4 (pid: 10, cores: 8)
spawned uWSGI worker 5 (pid: 11, cores: 8)
spawned uWSGI worker 6 (pid: 12, cores: 8)
spawned uWSGI worker 7 (pid: 13, cores: 8)
spawned uWSGI worker 8 (pid: 14, cores: 8)
WSGI app 0 (mountpoint='') ready in 5 seconds on interpreter 0x5595dab51e90 pid: 10 (default app)
WSGI app 0 (mountpoint='') ready in 6 seconds on interpreter 0x5595dab51e90 pid: 1 (default app)
WSGI app 0 (mountpoint='') ready in 7 seconds on interpreter 0x5595dab51e90 pid: 13 (default app)
WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x5595dab51e90 pid: 11 (default app)
WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x5595dab51e90 pid: 8 (default app)
WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x5595dab51e90 pid: 12 (default app)
WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x5595dab51e90 pid: 9 (default app)
WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x5595dab51e90 pid: 14 (default app)
Thu May 11 10:09:57 2023 - uwsgi_response_sendfile_do(): Connection reset by peer [core/writer.c line 655] during GET /bower_components/c3/c3.min.js (172.23.0.3)
OSError: write error
[pid: 11|app: 0|req: 7/30] 172.23.0.3 () {62 vars in 1707 bytes} [Thu May 11 10:10:03 2023] POST /faceb/bus => generated 188 bytes in 14 msecs (HTTP/1.1 501) 2 headers in 93 bytes (1 switches on core 6)

For me it looks like the proxy is not waiting long enough the answer and close the connection earlier.
This is probably because you are using lazy-apps so trytond is not started directly but only on the first request but the starting of trytond may take times.

Thank you for your answers.
I tried both suggestions. But I get the same error message (bad gateway) after 3 clicks!
I also tried removing the Threads, playing with the timeout, keepalive but nothing changes!
I also added workers, processes.
Do you have a docker configuration with uwsgi or without that works?

msg=“‘500 Internal Server Error’ caused by: http: server closed idle connection”
msg=“‘502 Bad Gateway’ caused by: readfrom tcp 172.23.0.3:53680->172.23.0.6:8000: write tcp 172.23.0.3:53680->172.23.0.6:8000: write: broken pipe”

The one from the docker image: 6.8/uwsgi.conf · dde2c5144f86b42e78f2b0f1960af44d1b391e40 · Tryton / Tryton Docker · GitLab