question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new connected channels may fail to receive message from group_send()

See original GitHub issue

It looks occasionally some channels won’t receive messages from using group_send(), although they all successfully connected to our server. Disconnected and re-connect may resolve the issue. Here is the sample:

two clients connected via websocket and joined a same group partner_orders_1531

127.0.0.1:6379[1]> zrange asgi::group:partner_orders_1531 0 -1 withscores
1) "specific.mrOZIufu!GAaMMeISqdry"
2) "1549585254.4294083"
3) "specific.qUSiCEQD!TGlphabkczyd"
4) "1549585307.3211055"

then calling async_to_sync(channel_layer.group_send)

channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(partner_order_group_name, order_data)

but only one channel with channel name qUSiCEQD!TGlphabkczyd was able to receive the message and triggered

class PartnerOrderConsumer(WebsocketConsumer):
        ...
        def order_receive(self, event):
            self.send(text_data=event["text"])

related redis log : image

Pip & Environment: Python 3.6.6 channels==2.1.5 channels-redis==2.3.1 daphne==2.2.3 Django==1.11.10 The server is hosted on Ubuntu 16.04.5 LTS with 2vCPUs/4GB MEMORY by Digitalocean. We have two daphne instances and using nginx for load balancing.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:35 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
xuehaozecommented, Feb 8, 2019

same issue here, please help, thanks!

2reactions
qeternitycommented, Mar 25, 2019

We experience this issue as well. At first we thought it was an issue with the channels-redis backend so we moved over to a rabbitmq backend, but this has not solved the problem. It seems that daphne workers timeout to their backend and stop receiving subscribed group_sends

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Channels group send only sends the message to last ...
it receive the message from a channel and send back to that channel to the number of connected channels in chat_room. ~ thanks...
Read more >
Channel Layers — Channels 4.0.0 documentation
Any message sent to that channel name - or to a group the channel name was added to - will be received by...
Read more >
Tests randomly failing with error "No connection could be ...
I am randomly getting the below error while executing the test but second time same test executes successfully. Tests executed from the automation...
Read more >
Introduction to Django Channels - TestDriven.io
Inside receive() we parsed the data to JSON and extracted the message . Then, we forwarded the message using group_send to chat_message ....
Read more >
Django Channels and WebSockets - LogRocket Blog
Learn how to use Django Channels and WebSockets, a new protocol that ... res): """ Receive message from room group """ # Send...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found