Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longpolling problems with multiple workers #283

Closed
fractalf opened this issue Nov 22, 2019 · 5 comments
Closed

Longpolling problems with multiple workers #283

fractalf opened this issue Nov 22, 2019 · 5 comments

Comments

@fractalf
Copy link

Has anyone managed to get the longpolling set up correctly witn Odoo 12 running in docker with multiple workers?

I get this error in the log:

> /usr/lib/python3/dist-packages/odoo/addons/bus/controllers/main.py(37)poll()
-> raise Exception("bus.Bus unavailable")

This is the actual XHR call (formated as a curl to get all the data) that just hangs after the error

curl 'http://localhost:8069/longpolling/poll' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: http://localhost:8069' -H 'Connection: keep-alive' -H 'Referer: http://localhost:8069/web' -H 'Cookie: session_id=e17e1a94dd4f87ffd8d89b4c1b91bfc9c136f1de; frontend_lang=en_US; adminer_sid=09269b28f0fc6259f9d24f90378ff292; adminer_key=a18ae9f428ce184a218a973675d81238; adminer_version=4.7.5' --data '{"jsonrpc":"2.0","method":"call","params":{"channels":[],"last":0,"options":{"bus_inactivity":185712}},"id":669926782}'

Searched high and low for a solution and tried a lot, but I'm stuck..

odoo.conf

[options]
workers = 5
proxy_mode = True
longpolling_port = 8072
data_dir = /var/lib/odoo

docker-compose.yml

...
        ports:
            - "8069:8069"
            - "8071:8071"
            - "8072:8072"
...
@codeagencybe
Copy link

@fractalf
I had exactly the same problem (Also Odoo 11 and 13 btw) and got it working by changing the nginx configuration.
I'll enclose the settings I'm using for Odoo 13 which you can also apply on Odoo 12 as below.
This one works 100% for me.
And it also solves the problem from the live chat. Because you have that bus error, the live chat also does not work properly.
If you sent a chat message, your view is not updating. You have to manually refresh your screen to see the new messages. Very irritating.
With the below settings, everything is fixed.

In your Docker container, you need to make sure you have these global dependencies (refers to psycogreen and gevent:

apt-get install apt-utils git nano pgbadger unzip libmagic-dev python-renderpm
pip3 install psycogreen zeep pstats_print2list simplejson plaid-python xlrd phonenumbers pyOpenSSL asn1crypto bcrypt boto3 botocore certifi cffi chardet cryptography docutils dropbox gevent greenlet idna jmespath paramiko pyasn1 pycparser pynacl pyocclient pysftp requests s3transfer urllib3 num2words pyldap qrcode vobject watchdog xlwt firebase-admin odoo_import_export_client

Next your odoo.conf as below

workers = 1 or higher. (depends on your server resources)
longpolling_port = 8072
max_cron_threads = 2 or more (depends again on your server resources)
xmlrpc = True
xmlrpc_interface = 
xmlrpc_port = 8069
xmlrpcs = True
xmlrpcs_interface = 
xmlrpcs_port = 8071
proxy_mode = True

Make sure you have proxy_mode = true set!!

Next your NGINX configuration.
I'm using a DevOps platform to deploy my applications, so some elements are variables which are auto replaced by the value from the DevOps platform.

upstream odoo {
 server $serviceName:8069;
}

upstream odoo-chat {
 server $serviceName:8072;
}

server {
  listen $mainPort;
  $serviceNginxHTTPS
  root /var/www/$serviceName;
  server_name $serviceDomains;
  server_tokens off; ## Don't show the nginx version number
  index index.html;
  resolver 172.17.0.1 valid=60s ipv6=off;
  set $backend $serviceName;
  include conf.d/letsencrypt.inc;
  location ~ /\.git {
    deny all;
  }
  
   proxy_read_timeout 720s;
   proxy_connect_timeout 720s;
   proxy_send_timeout 720s;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Real-IP $remote_addr;

   location / {
     proxy_redirect off;
     proxy_pass http://odoo;
   }

   location /longpolling {
       proxy_pass http://odoo-chat;
   }

   location ~* /web/static/ {
       proxy_cache_valid 200 90m;
       proxy_buffering    on;
       expires 864000;
       proxy_pass http://odoo;
  }

  

  try_files $uri/index.html $uri @app;
  location @app {
    proxy_pass        http://$backend:$servicePort;
    proxy_redirect    off;
    proxy_set_header  Upgrade $http_upgrade;
    proxy_set_header  Connection "upgrade";
    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-Proto $scheme;
  }
}

@zazula
Copy link

zazula commented Nov 23, 2019

I'm having the same problem just running Odoo in a docker container without any proxying.

Is there a config that allows multiple workers when connecting directly to the docker port?

@fractalf
Copy link
Author

@codeagencybe Thanks a lot for you input. Would you also care to share your docker-compose.yml ? I don't use an nginx-proxy when developing locally, maybe I need that to get this working

@fractalf
Copy link
Author

I managed to get it working, and I think I discovered a very weird thing (bug? unexpected behaviour?)

First, the reason it didn't work for me is because I was starting odoo like this (from entrypoint.sh)

..
exec odoo --dev=all "$@" "${DB_ARGS[@]}"
..

Note the optional --dev-all which I'm using (https://www.odoo.com/documentation/12.0/reference/cmdline.html#advanced-options). This actually stops the Event Service (longpolling) from starting! That's not expected..

Removing this argument and just using the default, and thing works..

..
exec odoo "$@" "${DB_ARGS[@]}"
..

...will file a bug report for this

I spend a whole day debugging this silly bug :/ Thanks to https://github.com/idazco/odoo-docker-ez (which works) I was able to narrow it down to this.

@IDCOLL
Copy link

IDCOLL commented Feb 24, 2021

@codeagencybe I have multiple dockers installed on my server. Do you think your solution will still work?

Also what is the $serviceName variable in your Nginx config?
The image below shows all of the dockers running.
image

Below is my Nginx config file for one of the sites....

server {
	root /var/www/html;
	index index.html index.htm index.nginx-debian.html;
	server_name website.co.za www.website.co.za;

	location / {
		proxy_read_timeout 720s;
        proxy_connect_timeout 720s;
        proxy_send_timeout 720s;
		proxy_pass http://127.0.0.1:8069;
		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-Proto $scheme;
	}

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/www.website.co.za/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.website.co.za/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot

}

server {
	listen 80;
	listen [::]:80;
	root /var/www/html;

	index index.html index.htm index.nginx-debian.html;
	server_name website.co.za www.website.co.za;

	location / {
		proxy_read_timeout 720s;
        proxy_connect_timeout 720s;
        proxy_send_timeout 720s;
		proxy_pass http://127.0.0.1:8069;
		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-Proto $scheme;
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants