django-channels

How to config supervisor with Django channels and server daphne

只谈情不闲聊 提交于 2019-12-11 15:17:28
问题 I have a problem with my configuration supervisor, my file is in etc/supervisor/conf.d/realtimecolonybit.conf , When I try command supervisorctl reread, show me the "No config updates to processes" and when I try the other command like this supervisorctl status realtimecolonybit Shows me this error realtimecolonybit FATAL can't find command '/home/ubuntu/realtimecolonybit/bin/start.sh;' And when try the supervisorctl start realtimecolonybit show me this error realtimecolonybit: ERROR (no such

Cross Site Request Forgery protection with Django and websockets

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 13:54:57
问题 I've successfully created a websocket on my Django(v. 2.0)-powered website using Django channels (v. 2.1.5). Everything is fine but I'm wondering what about CSRF token. Is it needed in case of websockets? Documentation says that it's enough to use OriginValidator to prevent such thread but I'd like to ensure that. I mean, what has happend to CSRF token? Am I just sending data through secure channel without it and backend automagically checks everything? And if that's so then why? And why

Django-Channels 2 not persisting session data set in `connect`

独自空忆成欢 提交于 2019-12-11 05:30:02
问题 channels==2.1.2 | channels-redis==2.2.1 | daphne==2.2.0 | Django==1.11.6 I've upgraded to Channels 2 specifically for the ability to access and modify the session from within a consumer (and access it in a view), but that doesn't seem to be working. Basically, I want to identify AnonymousUser s and send them messages (each his own, not all of them together). Here's my routing.py file: application = ProtocolTypeRouter({ # (http->django views is added by default) 'websocket':

How to integrate channels and DRF together

拥有回忆 提交于 2019-12-11 01:48:17
问题 I'm currently trying to create a backend server to communicate with some clients with a websocket. The clients makes some request to the backend and the backend responds directly to the client through a consumer. In addition, I've got an API that needs to send some requests to the client. It has to go through the opened socket of the consumer. I'm using Django Rest Framework for the API. So I've got 2 apps for now. One for the consumer and one for the API. I want to know if it's the correct

Running multiple instances of daphne behind a load balancer: django-channels

為{幸葍}努か 提交于 2019-12-11 01:14:35
问题 I am using django-channels to add HTTP2 & WebSocket support for my application. I could not find a lot of documentation as to how to scale channels. Below is my nginx configuration that load balances multiple instances of daphne running on the same machine but different ports. Is this the correct way to do it? upstream socket { least_conn; server 127.0.0.1:9000; server 127.0.0.1:9001; server 127.0.0.1:9002; server 127.0.0.1:9003; } server { listen 80; server_name 127.0.0.1; location =

Reusing an existing websocket in Django Channels

血红的双手。 提交于 2019-12-11 01:11:52
问题 I'm messing around semi-seriously with Python to create a sort of a gatekeeper server between a restricted-access system and a GAE application. I'm going to start with a more general question, before potentially moving on to a specific code-related question. Overview The restricted-access system is set up with a command-line Python app that opens a WebSocket connection to the Django Channels app running on an intermediate server, and begins sending out regular heartbeat frames, which the

Nginx with Daphne gives 502 Bad Gateway

此生再无相见时 提交于 2019-12-11 00:47:19
问题 I decided to replace uwsgi with daphne since I was having issues with Django Channels and uwsgi. After following this tutorial. I configured my nginx this way in sites-enabled. Most of the other examples I have come across are not using daphne so I could not relate to them. server { # the port your site will be served on listen 80; server_name .MyDomain.com; charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { # your Django project's

Django 'AsgiRequest' object has no attribute 'content_type'

廉价感情. 提交于 2019-12-11 00:28:39
问题 I am working on developing a django app named app, which is a part of a django project, but i am getting some problems when try to login admin. import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'something' DEBUG = True ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'connections', 'custom_user',

How to build a system to handle MQTT broker and Django

穿精又带淫゛_ 提交于 2019-12-10 23:44:02
问题 I am planning to build a home automation system where IoT devices communicate with the MQTT broker.The system also involves a Django web server that serves API for ios/android devices. I will describe an example of what I want to implement. An API call is made from mobile app to Django server to turn ON a device. When such API request is made to Django, it should push 'Turn ON' data to IoT device via MQTT protocol. Also, IoT devices send some real time data to the MQTT broker. Upon receiving

How do I send channels 2.x group message from django-celery 3 task?

守給你的承諾、 提交于 2019-12-10 18:56:09
问题 I need to postpone sending channels message. Here is my code: # consumers.py class ChatConsumer(WebsocketConsumer): def chat_message(self, event): self.send(text_data=json.dumps(event['message'])) def connect(self): self.channel_layer.group_add(self.room_name, self.channel_name) self.accept() def receive(self, text_data=None, bytes_data=None): send_message_task.apply_async( args=( self.room_name, {'type': 'chat_message', 'message': 'the message'} ), countdown=10 ) # tasks.py @shared_task def