如何要求枪支并与达芙妮做出回应?使用Django频道,Nginx,Gunicorn,Daphne
我在与Nginx,Daphne和Gunicorn一起部署Django应用程序时面临一个奇怪的问题。
截至目前,我已经成功部署了我的Django应用程序。 我的HTTP请求由Gunicorn处理,WSS请求由达芙妮(Daphne)处理,这本来可以发生。
考虑一个方案,我将HTTP请求发送给Gunicorn,Django需要通过频道发送消息。我该怎么做?
例如,如果我通过http post请求添加了帖子,并且想通过渠道向所有开放渠道发送通知(我有一个列表),即使在要求HTTP首先是通过枪支收到的吗?
我需要的请求流是:
客户端> http> nginx> Gunicorn> django>进行一些处理>通过WSS&GT将通知发送到所有开放渠道;发送http响应ok状态= 200给客户端
我使用本指南来部署
https://github.com/mitchtabian/howto-django-channels-daphne/blob/blob/master/master/readme.md
一切正常,除了我没有在客户端网络网络上收到WSS消息,当我将HTTP请求发送给Gunicorn时,但是当我向Daphne发送HTTP请求时,我会成功获得WSS响应
I'm facing a strange issue in deploying Django app with Nginx, Daphne and Gunicorn.
As of now, I have successfully deployed my Django app.
My HTTP requests are handled by Gunicorn, and WSS requests are handled by Daphne, which is meant to happen.
Consider a scenario, where I send an HTTP request to Gunicorn, and Django needs to send a message back via channels. How do I do that?
For example, if I add a post via HTTP POST request, and want to send a notification via channels to all the open channels (which I have a list of) how do I make Django send back a channel message through Daphne, even when the request was HTTP in the first place received through Gunicorn?
The request flow that I need is:
Client > HTTP > NGINX > GUNICORN > DJANGO > Do some processing > Send notification to all open channels via WSS > Send HTTP RESPONSE OK STATUS=200 to client
I used this guide to deploy
https://github.com/mitchtabian/HOWTO-django-channels-daphne/blob/master/README.md
Everything is working fine except I don't receive WSS messages on the client WebSocket listener, when I send a HTTP request to Gunicorn, but when I send HTTP request to Daphne I get a WSS response successfully
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要配置a Channel layer layer :
channels_redis 是一个很好的选择,是将消息从服务器传输到另一个。
请求流将是:
You need to configure a Channel Layer:
channels_redis is a good one, to transfer a message from a server to another.
The request flow will be: