frappe / frappe_docker

Docker images for production and development setups of the Frappe framework and ERPNext
MIT License
1.4k stars 1.32k forks source link

WebSockets / socket.io issue with docker install #1456

Closed oleynikd closed 1 month ago

oleynikd commented 1 month ago

Hello, Websockets are not working with docker instal. I tried both pwd.yml and custom images with docker compose config - same result. When I open the app in browser I see error in logs:

socketio_client.js:49 WebSocket connection to 'wss://xxxx/socket.io/?EIO=4&transport=websocket&sid=elHjhjQeQBL4OM48AAAv' failed: WebSocket is closed before the connection is established.

As you can imagine, live data updates doesn't work. If I ask console frappe.realtime.socket.connected it says false.

Screenshot 2024-08-09 at 02 11 18

All my containers are working. websocket container is up and healthy. Here's the common_site_config.json:

{
 "db_host": "db",
 "db_port": 3306,
 "default_site": "myerp",
 "redis_cache": "redis://redis-cache:6379",
 "redis_queue": "redis://redis-queue:6379",
 "redis_socketio": "redis://redis-queue:6379",
 "socketio_port": 9000
}

It is not a local install. This runs on remote server with SSL enabled. Installed apps:

ERPNext: v15.32.1
Frappe Framework: v15.37.0
Frappe HR: v15.25.2

Please help me to figure out what is wrong. Thanks. 🙏

oleynikd commented 1 month ago

The problem was with the FRAPPE_SITE_NAME_HEADER env variable. I set it to a custom name like myerp, but I had to use full domain name (which is actually described here). This value will be used (among others) by nginx proxy to pass requests to socket.io server here. Once I changed it and recreated my site - everything is working.