Skip to content

Multiple Entries being saved in Database when using ReconnectingWebSocket with django-channels #115

Open
@pirateksh

Description

@pirateksh

I have made a simple Real-Time Chat Application using Django-channels.

I have made a consumer named ChatConsumer which inherits from AsyncConsumer.

It has methods websocket_connect(), websocket_receive() and websocket_disconnect().

Additionally, I have defined two more methods namely get_thread() and create_chat_message() which interact with the database.

Among these methods, create_chat_message() is the method that actually saves the chat message into the database. It is called from the websocket_receive() method.

The issue I am facing is that, when I use ReconnectingWebSocket, somehow the message received in the websocket_receive() method is saved multiple times in the database.

However, if I use vanilla WebSocket, everything works fine.

I also have also posted about the same issue on StackOverflow which I encountered about a year ago when I was working on a different project. Here is the link to it.

I have been able to reproduce this bug two times in two different projects, so, I am pretty sure that it is somehow related to ReconnectingWebSocket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions