django-channels

API request to already opened django channels consumer

旧时模样 提交于 2019-12-22 01:19:49
问题 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

How to authenticate a user in websocket connection in django channels when using token authentication [duplicate]

混江龙づ霸主 提交于 2019-12-21 02:55:21
问题 This question already has answers here : How do you authenticate a websocket with token authentication on django channels? (5 answers) Closed 7 months ago . I am using a frontend framework (Vuejs) and django-rest-framework for the REST API in my project. Also, for JSON web token authentication I am using django-rest-framework-jwt. After a successful login, the user is provided with a token. This token is passed into every request to fetch any API related stuff. Now I would like to integrate

Django channels 2, accessing db in tests

▼魔方 西西 提交于 2019-12-14 01:43:40
问题 I recently updated my project to Django 2 and channels 2. Right now I am trying to rewrite my tests for chat app. I am facing a problem with tests that depend on django db mark from pytest-django. I tried to create objects in fixtures, setup methods, in test function itself, using async_to_sync on WebsocketCommunicator . However, none of those worked. If I create a user in a fixture and save it correctly gets an id. However, in my consumer Django does not see that User in the database. And

How can I add a user whose ID I know to a Django Channels channel_layer group?

心已入冬 提交于 2019-12-13 02:55:34
问题 I am writing a web-application using websockets from django-channels. In which: Customer users can make orders from store users. When a user requests an order via their communicator, I create a channel group using the order's id. The store related to this order should be added to this channel group as well. This is what I'm struggling to achieve. This logic can be seen in my pytest below: async def test_store_is_added_to_order_group_on_create(self, settings): customer = await create_customer(

New chat message notification Django Channels

女生的网名这么多〃 提交于 2019-12-12 07:49:43
问题 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

WebRTC video/audio calling failed 90% of time on different network but got success 90% on same network

醉酒当歌 提交于 2019-12-12 05:28:02
问题 I have created video chat app using webRTC and Django channel.My app working 90% of time properly when using it in the same network but fail when using it on a different network.I am not able to see a video of remote person when using it on a different network. I used chrome://webrtc-internals/ to trace my webRTC response and I got iceconnectionstate : failed when called using different network Below screenshot is taken when I got success in the same network And after success also it gave

django channels integration issue, websocket.receive not listening

与世无争的帅哥 提交于 2019-12-12 02:38:49
问题 Going through various blog post, I am trying to implement django channels for websockets functionality with django I am using django 1.9.1 with these set of dependencies: asgi-redis==0.10.0 channels==0.12.0 daphne==0.11.1 settings.py CHANNEL_LAYERS = { "default": { "BACKEND": "asgiref.inmemory.ChannelLayer", "ROUTING": "test.routing.channel_routing", }, } routing.py from channels.routing import route from .consumers import websocket_receive channel_routing = [ route("websocket.receive",

ChannelsLiveServerTestCase failing with error while following Django Channels tutorial (part 4)

耗尽温柔 提交于 2019-12-11 17:53:40
问题 I am trying to follow the 4 part channels tutorial, however I am getting an error on the last part where we run selenium to test against a live server. It's not the end of the world as I can still run the server with no problems, however it limits my ability to test which is a shame. I have the full details in the closed issue below (to avoid repetition) https://github.com/django/channels/issues/1207 I have somehow also managed to get these tests to run and pass with channels version 2.0.2

sending notification to one user using Channels 2

帅比萌擦擦* 提交于 2019-12-11 17:21:48
问题 I want to send notification to specific authenticated user using Channels 2. In below code i am sending notification as a broadcast instead of that i want to send notification to a specific user. from channels.generic.websocket import AsyncJsonWebsocketConsumer class NotifyConsumer(AsyncJsonWebsocketConsumer): async def connect(self): await self.accept() await self.channel_layer.group_add("gossip", self.channel_name) print(f"Added {self.channel_name} channel to gossip") async def disconnect

AttributeError: module 'pkg_resources' has no attribute 'safe_name' django channels redis

筅森魡賤 提交于 2019-12-11 16:30:46
问题 I'm trying to install channels_redis and got following error. pip install channels_redis Collecting channels_redis Using cached https://files.pythonhosted.org/packages/63/ae/adea3b1913aebb84ec6b6f3c30ba81b8bef79f99b51c7240810284152df4/channels_redis-2.2.1-py2.py3-none-any.whl Requirement already satisfied: channels~=2.0 in ./env/lib/python3.6/site-packages (from channels_redis) (2.1.1) Requirement already satisfied: asgiref~=2.1 in ./env/lib/python3.6/site-packages (from channels_redis) (2.3