0
votes

I have been following the official Django Channels tutorial on the Chat Room. ChatRoom - Synchronous Tutorial

However, even following every steps and double checking, I keep on having the same issue: The tutorial mentions the fact that both users, accessing the same chat room (and thus same group name) should receive messages from each other in both browser tabs opened.

  • If I send a message from tab 1, I can't see my message in tab 1 but I can in tab 2.
  • If I send a message from tab 2, I can see the message duplicated on tab 2, nothing on tab 1.

This issue arises on the synchronous tutorial and the asynchronous one as well.

Did anyone have the same issue?

I can't see what I've done wrong while following the tutorial. I am using Django/Channels latest version with Python 3.9 and the Redis version mentioned on the tutorial.

Thank you.

1
After more debugging, I suspect the self.send(...) line in the chat_message() event. As both tabs are opened and connect to the same web socket, isn't this line sending only to the 2nd tab as it was the last to access the web socket? Shouldn't we loop through each connected client and send the message individually? Maybe I am completely wrong here, but this is what I would imagine.David

1 Answers

0
votes

Found it: it was a bug and an update to channels 3.0.1 fixes it (I was using 3.0.0) . I just spotted someone who reported it a few hours ago at Issue 1566 Just tried it and it works like a charm!