This question has been flagged
3 Replies
42942 Views

Hello there,
I'm facing an issue with Odoo version 11. I'm getting Longpolling error in my Inspector.

Here's the error log from Nginx:

2018/01/13 09:33:31 [error] 20300#20300: *476 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XX.XX.XX, server: , request: "POST /longpolling/poll HTTP/1.1", upstream: "http://127.0.0.1:8072/longpolling/poll", host: "XX.XX.XX.XX", referrer: "http://XX.XX.XX.XX/web"

2018/01/13 09:33:42 [error] 20300#20300: *476 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XX.XX.XX, server: , request: "POST /longpolling/poll HTTP/1.1", upstream: "http://127.0.0.1:8072/longpolling/poll", host: "XX.XX.XX.XX", referrer: "http://XX.XX.XX.XX/web"


I'm using Nginx as a reverse proxy, and here's my config:

upstream backend-odoo {

server 127.0.0.1:8069;

}

upstream backend-odoo-im {

server 127.0.0.1:8072;

}

server {

listen 80;

#server_name yourdomainname.com;

add_header Strict-Transport-Security max-age=2592000;

location / {

proxy_pass http://backend-odoo;

proxy_read_timeout 300000;

# proxy header and settings

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_redirect off;

# odoo log files

access_log /var/log/nginx/odoo-access.log;

error_log /var/log/nginx/odoo-error.log;

# increase proxy buffer size

proxy_buffers 16 64k;

proxy_buffer_size 128k;

# force timeouts if the backend dies

proxy_next_upstream error timeout invalid_header http_500

http_502 http_503;

# enable data compression

gzip on;

gzip_min_length 1100;

gzip_buffers 4 32k;

gzip_types text/plain application/x-javascript text/xml text/css;

gzip_vary on;

client_max_body_size 500M;

}

location ~* /web/static/ {

# cache static data

proxy_cache_valid 200 60m;

proxy_buffering on;

expires 864000;

proxy_pass http://backend-odoo;

}

location /longpolling {

proxy_pass http://backend-odoo-im;

}

}

Since I'm running Odoo on a remote server with 1CPU, I changed the number of workers to be 3 and enabled proxy mode.

Here's my Odoo config, I changed only two parameters:

proxy_mode = True

workers = 3


I'm not quite sure what's wrong with these configurations and why I'm getting this error!


Avatar
Discard
Best Answer

Let's just say you have a longpolling parameter in your odoo.conf

longpolling_port = 8072

after starting your odoo, just runs $ sudo netstat -tulpn to ensure that your longpolling is running, and you'll get this info :

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp 0 0 0.0.0.0:8072 0.0.0.0:* LISTEN 10121/python3
tcp 0 0 0.0.0.0:8069 0.0.0.0:* LISTEN 10119/python3
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1461/sshd
...

when you can't find your longpolling there (that's why Bad Gateway Occurs, nginx can not find the running longpolling port), maybe just need to install gevent first:

$ sudo pip3 install gevent

and restart your odoo.
check $ sudo netstat -tulpn again, and you'll see that your longpolling port already running..

it works on me, just try..


Avatar
Discard
Best Answer

On my setup (Odoo 12 deployed using Docker), behind Nginx proxy, I had to set

workers = 2

in the config file to see Odoo correctly launching the "longpolling" thread.

Avatar
Discard

Worked for Odoo 11 source install too.

Best Answer

You must set longer timeout:

These timeout settings can be placed in 'location' block or 'server' block

location /longpolling {
    proxy_connect_timeout 600; proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
proxy_pass http://backend-odoo-im;
}
Avatar
Discard