I have django app and implementing websocket support with channels and channels api. I am using demultiplexer with bindings to my models. For example when i save a model it will send the change to my open websocket connection.
Everything works OK if i run ./manage.py runserver 0:80
and have all in one container. But if i separate my app to UWSGI, daphne and the worker containers using docker the signals are not triggered. For example i want any celery worker (task) to trigger the signal and send update via the websocket. In my multicontainer setup the websocket connection is established OK and web works OK, but nothing triggers that signals.
How the signals are defined you can see here on github.
I am using django 1.9.12, python 2.7, docker and build on debian stretch.
docker-compose.yml
web:
build: .
ports: ["8001:80"]
daphne:
build: .
command: daphne -b 0.0.0.0 -p 8000 --access-log - -v 2 my_proj.asgi:channel_layer
ws_worker:
build: .
command: ./manage.py runworker -v 2
celery_worker:
build: .
command: /usr/local/bin/celery -A my_proj worker
nginx.conf
upstream django {
server unix:/home/docker/app.sock;
}
server {
listen 80;
server_name 127.0.0.1;
charset utf-8;
client_max_body_size 1000M;
location /static/ {
alias /home/docker/static/;
}
# proxy to other container
location /ws/ {
proxy_pass http://daphne:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
uwsgi_pass django;
include /home/docker/uwsgi_params;
}
}