django-channels

Push live updates to client through Django Channels & Websockets

安稳与你 提交于 2019-12-05 02:24:34
问题 I'm trying to make a page which shows live-updating data to the client. The rest of the site is built with Django, so I'm trying to use Channels for this. The data I am displaying is saved in both a JSON file and a MySQL database for further calculations in other parts of the site. Ideally, I would like to display the latest data received (that is, when the file updates) to the client as it is received. And even though as I understand Channels are built exactly for this purpose, I am having

API request to already opened django channels consumer

て烟熏妆下的殇ゞ 提交于 2019-12-04 20:38:20
I've got a django channels consumer communicating with a client. I've got a view from an external API that wants something from the client. From this view I want then to tell that consumer to ask a request to the client through his socket. I'm currently exploring django rest framework but I can't find a way for now to directly ask anything to that consumer. Well I've got an idea but it involves creating another socket and communicate through channels' channel. But I wish I could get rid of this overload. Ken4scholars From your reponse in the comments, it seems you want to send a message to the

Websocket using Django Channels

回眸只為那壹抹淺笑 提交于 2019-12-04 17:02:17
I am trying to use Django channels to establish a websocket connection with the browser. The websocket fails to connect with the server: [2017/01/23 23:51:50] HTTP GET / 200 [0.03, 127.0.0.1:60445] [2017/01/23 23:51:51] WebSocket HANDSHAKING /chat/ [127.0.0.1:60451] [2017/01/23 23:51:56] WebSocket DISCONNECT /chat/ [127.0.0.1:60451] Javascript used for websocket: socket = new WebSocket("ws://" + window.location.host + "/chat/"); socket.onmessage = function (e) { alert(e.data); }; socket.onopen = function () { socket.send("hello world"); }; // Call onopen directly if socket is already open if

Django channels 'No application configured for scope type 'websocket''

為{幸葍}努か 提交于 2019-12-04 05:17:26
问题 I am trying to implement a chat with Django and channels according to this tutorial (http://channels.readthedocs.io/en/latest/tutorial/part_2.html). I add channels and a chat app to installed apps. I make the following routings for a project: # mysite/routing.py from channels.routing import ProtocolTypeRouter application = ProtocolTypeRouter({ # (http->django views is added by default) }) Basically, I did exactly the steps from the tutorial. But after runserver I am still getting ValueError:

Sending webRTC video stream to server with django channels

◇◆丶佛笑我妖孽 提交于 2019-12-03 20:40:49
I am trying to create a face detection web application written in django. The app works this way. The user navigates to the url The camera starts on the client machine Each frame is then sent to the server for face detection Processed frame is then displayed on the web page I understood I could not use opencv VideoCapture because, it only works on the server side. When I read online people asked me to use javascript and specifically webRTC to start live stream on the client side. So I found this tutorial which explains how to start webcam on the client machine with javascript. Now my question

Push live updates to client through Django Channels & Websockets

╄→гoц情女王★ 提交于 2019-12-03 20:12:16
I'm trying to make a page which shows live-updating data to the client. The rest of the site is built with Django, so I'm trying to use Channels for this. The data I am displaying is saved in both a JSON file and a MySQL database for further calculations in other parts of the site. Ideally, I would like to display the latest data received (that is, when the file updates) to the client as it is received. And even though as I understand Channels are built exactly for this purpose, I am having trouble doing it. I have tried sending multiple requests from the client-side with delay and loops in

Django channels - Echo example not working

蓝咒 提交于 2019-12-03 12:23:46
问题 I'm following the instructions in the documentation site, but I got stuck in the echo example, the websocket is created correctly and it's connected to the server but when I send anything to the server I'm not getting any response (In the example says I should see an alert window with the same message that I send into the socket but I don't, although I've changed the alert for a console.log but still), what I'm doing wrong? In settings.py : INSTALLED_APPS = { ... 'channels', 'myapp', ... } ..

New chat message notification Django Channels

对着背影说爱祢 提交于 2019-12-03 12:22:56
I've got Django Channels 2.1.2 set up in my Django app by following a tutorial and now need to set up a notification system for new messages. I want to do this in the simplest way possible. I can do it via browser push notifications, but I don't want to do it like that. I want it to be like Stack Overflow, where there is a red number representing the instance of a new message. One answer on here said For notifications you only need two models: User and Notification . On connect set the scope to the currently authenticated user. Set up a post_save signal on your Notification model to trigger a

Sending messages to groups in Django Channels 2

时光总嘲笑我的痴心妄想 提交于 2019-12-03 09:23:02
问题 I am completely stuck in that I cannot get group messaging to work with Channels 2! I have followed all tutorials and docs that I could find, but alas I haven't found what the issue seems to be yet. What I am trying to do right now is to have one specific URL that when visited should broadcast a simple message to a group named "events". First things first, here are the relevant and current settings that I employ in Django: CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core

Django channels file/image upload

被刻印的时光 ゝ 提交于 2019-12-03 09:15:20
I would like to upload files and images using django-channels but i don't have any idea where to start. Seems like there is not much documentation about websockets and file/image uploads. Any ideas? I also faced the same problem and I solved it by uploading the the Image/File in S3 bucket. we just need to decode the base64 code and upload the file and return the URL to websocket. We can also provide preview of the image by providing the file type. def file_upload(self, data): # Convert decode the base64 data file = base64.b64decode(data['data']['content'].split(',')[-1]) filename = data['data'