Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Odoo Discuss Chat Messages Not Updating in Real-Time Without Refresh (Nginx + Longpolling Issue)

1 备注
形象
丢弃
形象
odoo
-

Hi, can you confirm if you use any load balancers?

1 答案
0
形象
odoo
最佳答案

Assessment of Nginx Configuration:

This Nginx configuration is largely correct and robust for Odoo's longpolling and WebSockets. Here are the key points:

  • Separate Upstreams (odoo17, odoo17chat): This is a clean way to define the main Odoo application and its longpolling backend.
  • Correct Ports: 1700 for main Odoo and 8072 for chat are correctly passed to the upstreams.
  • Essential Headers: X-Forwarded-Host, X-Forwarded-For, X-Forwarded-Proto, X-Real-IP are set for Odoo's Proxy Mode.
    • Note on X-Real-IP: If using Cloudflare, X-Real-IP $remote_addr; might pass Cloudflare's IP. For the actual client IP, it's often better to use proxy_set_header X-Real-IP $http_cf_connecting_ip; if Cloudflare is sending that header, or use Nginx's real_ip module. However, the provided config is standard without Cloudflare specifics.
  • WebSocket Headers (Upgrade, Connection): These are correctly included in the location /longpolling block.
  • proxy_http_version 1.1;: This is CRUCIAL for Nginx when proxying WebSockets, ensuring the HTTP/1.1 protocol upgrade works correctly. This is a common fix for real-time issues.
  • Timeouts: proxy_read_timeout, proxy_connect_timeout, proxy_send_timeout are set to 720s (12 minutes), which is generous and helps prevent premature disconnections for long-lived WebSocket connections.

Potential Minor Improvement for location /longpolling: The X-Forwarded-For and Host headers are already set in the main server block. While repeating them in location /longpolling is harmless, they are generally inherited. The Upgrade and Connection headers are the unique ones for this block.

"Do I need to adjust any Odoo settings for WebSockets to work properly?"

Yes, Odoo's odoo.conf needs to be correctly configured to work with this Nginx setup.

Assessment of Odoo odoo.conf settings:

  • http_port = 1700: This matches the odoo17 upstream in Nginx. Correct.
  • longpolling_port = 8072: This matches the odoo17chat upstream in Nginx. Correct.
  • proxy_mode = True: This is CRUCIAL for Odoo to correctly interpret the X-Forwarded-* headers from Nginx.
  • workers = 2: This enables multi-worker mode, which is good for production.
  • dbfilter = ^%h$: Correct for hostname-based multi-database setups.

Missing/Recommended Odoo Settings from your own troubleshooting journey (especially for Odoo 18):

Based on your recent successful troubleshooting, the following settings in odoo.conf are highly recommended for Odoo 18 stability and real-time performance:

  • Resource Limits:
    • limit_memory_hard = 2415919104 (e.g., ~2.25 GB per worker)
    • limit_memory_soft = 2013265920 (e.g., ~1.87 GB per worker)
    • limit_request = 8192
    • limit_time_cpu = 360
    • limit_time_real = 3600
    • limit_time_real_cron = 120 (Crucial for preventing cron timeouts)
  • WebSocket/Longpolling Specifics:
    • websocket_keep_alive_timeout = 600 (Helps maintain long-lived connections)
    • websocket_rate_limit_burst = 10
    • websocket_rate_limit_delay = 0.2
  • Session Storage (to prevent FileNotFoundError):
    • session_store = db (You already have this)
    • session_dir = False (Crucial to add, prevents Odoo from trying to write session files to disk when using session_store = db)
  • XML-RPC Configuration (for external integrations):
    • xmlrpc = True
    • xmlrpc_interface = 0.0.0.0
    • xmlrpc_port = 8069
    • xmlrpcs = True
    • xmlrpcs_interface = 0.0.0.0
    • xmlrpcs_port = 8071
 This worked for me!
                        
[options]
admin_passwd = ############
addons_path = /mnt/extra-addons,/usr/lib/python3/dist-packaes/odoo/addons
session_store = db
session_dir = False
limit_memory_hard = 2415919104
limit_memory_soft = 2013265920
limit_request = 8192
limit_time_cpu = 360
limit_real_time = 3600
limit_time_real_cron = 120
longpolling_port=8072
;logfile = /var/log/odoo/odoo-server.log
;logrotate = True
;log_level = debug
http_port =
;http_timeout = 1800
max_cron_threads = 2
workers = 5
websocket_keep_alive_timeout = 600
websocket_rate_limit_burst = 10
websocket_rate_limit_delay = 0.2
xmlrpc = True
xmlrpc_interface =
xmlrpc_port = 8069
xmlrpcs = True
xmlrpcs_interface =
xmlrpcs_port = 8071
proxy_mode = True
dbfilter = ^%h$

Conclusion:

The Nginx configuration is well-structured for longpolling. The Odoo odoo.conf is also good, but adding the specific limit_ and websocket_ parameters (especially session_dir = False and limit_time_real_cron) from your recent Odoo 18 troubleshooting will significantly improve stability and ensure real-time chat functions reliably.

形象
丢弃