-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Multiplexing with nginx causes model observation to fail silently #203
Comments
Update: on further testing sending requests via |
Hi @ihasdapie What channel layer are you using? So that the Django signals get registered you need to ensure you import the consumers, even for the WSGI server and your ssh session. The observation uses Django signals hooks so it needs to evaluate the files (import them) so that these hooks are registered on every instances not just the web-socket instance. |
Hey, thanks for the reply! I'm using the redis channel layer. I've imported all the consumers in the app config, should this be suffice to get it registered for both wsgi and asgi? This doesn't appear to work and I'm seeing the same behaviour as I mentioned previously between the For reference, i'm running wsgi via gunicorn and asgi via a gunicorn uvicorn worker
|
Switching to only using the asgi worker seemed to have resolved this problem. However, i'd still like to use the wsgi worker for handling everything but websocket. Not sure if it is out of scope, but is it possible to configure this? It appears that even if the consumers are loaded into wsgi, those events do not make it to django-channels. |
I should be possible to configure this. To confirm the consumers are imported within Are you able to connect to your redis dashboard to check if messages are being sent to redis? |
I am configuring the channels layer the same way for both asgi and wsgi. No messages appear to be sent to redis, however. In the meantime ive worked around it by using the uvicorn worker to serve everything |
Describe the bug
This is a really bizarre issue, and I don't really know where to start with it. I don't have a minimally reproducible example, but can try to create one later.
Basically, I'm trying to mutliplex my django service and another service serving the frontend behind the same domain (app.example.com) via the
X-Server-Select
header (as per following https://sites.psu.edu/jasonheffner/2015/06/19/nginx-use-different-backend-based-on-http-header/) to prevent having to preflight http requests.The problem is, when http requests are being made to the backend via
app.
(routed viaX-Server-Select
) while websocket is routed viaapi.
(no X-Server-Select), it appears that specifically model observation breaks. Consumers written withAsyncAPIConsumer
work flawlessly, and so does the initial handshake@action
-s for model observation (connection & authentication work correctly and we see responses from the backend over ws). However model changes triggered both by ssh-ing into a live server and running updates on the model via django shell, or via http requests to backend, do not work.And it works flawlessly if we don't have the X-Server-Select routing! The changes are entirely in nginx configuration.
I'm wondering if there is any hostname config or likewise assumption that this broke? Or if anyone has any suggestions as to where to look for solutions.
I've also tried putting ws under
app.
as well, but to the same issue.with logging i notice that the model observer never gets invoked, nor does the
groups_for_signal
. Which is really odd, since all the auth and setup functions work fine. And if i run frontend pointing toapi.
for requests, then the ws events works perfectly fine. Also when pointing toapp.
for http requests i have verified that the requests are going through and models are being correctly updated.(running in python:11.5:bullseye container)
Running asgi via daphne and wsgi via gunicorn
any ideas or help would be greatly appreciated. Thanks!
The text was updated successfully, but these errors were encountered: