Django channels websocket reconnect
问题 I am building a messaging system in Django, using web-socket to receive the message. Here is my tryouts, from channels.consumer import AsyncConsumer from channels.db import database_sync_to_async class ChatConsumer(AsyncConsumer): async def websocket_connect(self, event): print("connected", event) await self.send({ "type": "websocket.accept" }) async def websocket_receive(self, event): print("receive", event) message = event['text'] obj = await self.create_obj(message=message) print('Created.