Skip to content

Issue with duplicate keywordsΒ #1855

@emilycodestar

Description

@emilycodestar

Hello! Its are little bug report. If you have 2 django apps with diffrent consumers but on same url base, like that:

main
   > settings.py
   > etc..
app_1
  > consumer.py
  > channels_urls.py
app_2 
 > consumers.py

And if in channel layers we have same keywords, like "message", for both consumers,
socket will not work. So its pretty unexpactable because its have diffrenct consumers. Solution its just rename same keywords.
It will be pretty good if we have some info about it in documentation, because i spent a lot of hours on that problem :)

Here is example what will work

app_2

            async_to_sync(self.channel_layer.group_send)(
                f"user_chat{chat_room}",
                {
                    'type': 'message_user',
                    'chat_message': message,
                    'chat_username': self.scope['user'].username,
                }
            )

app_1

            async_to_sync(self.channel_layer.group_send)(
                "chat",
                {
                    'type': 'message_all',
                    'message': text_data,
                    'username': self.scope['user'].username,
                }
            )

and what will not work:

app_2

            async_to_sync(self.channel_layer.group_send)(
                f"user_chat{chat_room}",
                {
                    'type': 'message_user',
                    'chat_message': message,
                    'chat_username': self.scope['user'].username,
                }
            )

app_1

            async_to_sync(self.channel_layer.group_send)(
                f"user_chat{chat_room}",
                {
                    'type': 'message_user',
                    'chat_message': message,
                    'chat_username': self.scope['user'].username,
                }
            )

app_1 will work, app_2 is not :) pretty strange i guess,

Also thank for all contributors for this great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions