Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pirateksh opened this issue Oct 7, 2020 · 1 comment

Comments

@pirateksh
Copy link

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.

@pirateksh
Copy link
Author

I have observed one more thing about Multiple Entries Being saved.
Number of Times the same value is saved in database == Number of times the WebSocket connection reconnects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant