title: Websockets connection with asyncio
body: <p>I am trying to use websockets with DRF. I am new to asyncio in python. I am using django channels for websockets with redis server. Everything works fine for the first time, but when I reload the page in my browser the websocket connection disconnects after handshake. This is my consumer.py</p>
  <pre><code>import json
  
  from channels.generic.websocket import AsyncJsonWebsocketConsumer
  
  
  class GetPrice(AsyncWebsocketConsumer):
      async def connect(self):
          self.room_group_name = 'notify_price'
          # Join room group
          await self.channel_layer.group_add(
              self.room_group_name,
              self.channel_name
          )
          await self.accept()
          # print(f&quot;Added {self.channel_name} channel to gossip&quot;)
  
      async def disconnect(self, close_code):
          # Leave room group
  
          await self.channel_layer.group_discard(
              self.room_group_name,
              self.channel_name
          )
          # print(f&quot;Removed {self.channel_name} channel to gossip&quot;)
  
      # Receive message from WebSocket
      async def receive(self, text_data):
          # print('Entered in receive')
          text_data_json = json.loads(text_data)
          message = text_data_json['price']
  
          # Send message to room group
          await self.channel_layer.group_send(
              self.room_group_name,
              {
                  'type': 'chat.message',
                  'message': message
              }
          )
  
      # Receive message from room group
      async def chat_message(self, event):
          # Send message to WebSocket
          await self.send(text_data=json.dumps({
              'message': event['price'],
              'type': 'chat.message',
          }))
          # print(f&quot;Got message {event} at {self.channel_name}&quot;)
  </code></pre>
  <p>Get function looks like this in views.py</p>
  <pre><code>
      def get(self, request):
          app = App()
          asyncio.set_event_loop(asyncio.new_event_loop())
          asyncio.run(app.run())
          return Response(
              {'message': 'Done},
              status=status.HTTP_200_OK
          )
  </code></pre>
  <p>When I reload the webpage websockets gets disconnected, and no connection formed after handshake. Any help regarding this wil be highly appreciated.</p>