title: django channels Connection Errors only when tried with User_login
body: <p>Running channels with daphne.</p>
  
  <pre><code>django version: 2.0.4
  
  asgiref==2.2.0
  
  asgi-redis==1.4.3
  
  channels==2.1.5
  
  channels-redis==2.3.1
  </code></pre>
  
  <p>I'm trying to connect websoket. When I tried to connect with Anonymous user(without user login), it works well. But, when there is user, it doesn't work well.</p>
  
  <p>The one point that I get by using <code>pdb.set_trace()</code> is that there is <code>self.scope['cookies']['sessionid']</code> when I tried with user login. But there is no result in <code>self.scope['cookies']['sessionid']</code> when there is no user(Anonymous user)</p>
  
  <p>I thought that it might be related to <code>AuthMiddlewareStack</code> and I looked into the source code. But, I cannot find the source of the problem.</p>
  
  <p>Can you help me?
  Below are my codes.</p>
  
  <ol>
  <li><p>settings.py
  <pre><code>
  ASGI_APPLICATION = 'businessproject.routing.application'</p>
  
  <p>CHANNEL_LAYERS = {
      'default': {
          'BACKEND': 'channels_redis.core.RedisChannelLayer',
          'CONFIG': {
              "hosts": [('127.0.0.1', 6379)],
          },
      },
  }
  </pre></code></p></li>
  <li><p>models.py</p></li>
  </ol>
  
  <p><pre><code>
  class MyUser(AbstractUser):
      galaxy_num=models.IntegerField(default=1)
      onoff=models.IntegerField(default=1, null=True)</p>
  
  <pre><code>def __str__(self):
      return self.username
  </code></pre>
  
  <p></pre></code></p>
  
  <ol start="3">
  <li>consumers.py</li>
  </ol>
  
  <p><pre><code>
  from channels.generic.websocket import WebsocketConsumer, AsyncWebsocketConsumer
  import json, pdb
  from asgiref.sync import async_to_sync</p>
  
  <p>class TestConsumer(AsyncWebsocketConsumer):</p>
  
  <pre><code>async def connect(self):
      # Join room group
      self.group_name="likes"
  
      await self.channel_layer.group_add(
          self.group_name,
          self.channel_name
      )
  
      await self.accept()
  
  async def disconnect(self, close_code):
  
      await self.channel_layer.group_discard(
          self.group_name,
          self.channel_name
      )
  
  async  def receive(self, text_data):
      text_data_json = json.loads(text_data)
      message = text_data_json['message']
  
      await self.channel_layer.group_send(
          self.group_name,
          {
              'type': 'like_message',
              'message': message
          }
      )
  
  # Receive message from room group
  async def like_message(self, event):
      message = "%s님이 게시물을 좋아합니다."%event['message']
  
      # Send message to WebSocket
      await self.send(text_data=json.dumps({
          'message': message
      }))
  </code></pre>
  
  <p></pre></code></p>
  
  <ol start="4">
  <li>routing.py</li>
  </ol>
  
  <p><pre><code></p>
  
  <pre><code>from channels.auth import AuthMiddlewareStack
  from channels.routing import ProtocolTypeRouter, URLRouter
  from cebula import routing
  
  
  application = ProtocolTypeRouter({
      # (http-&gt;django views is added by default)
      'websocket': AuthMiddlewareStack(
          URLRouter(
              routing.websocket_urlpatterns
          )
      ),
  })
  </code></pre>
  
  <p></pre></code></p>
  
  <p>this is the console result</p>
  
  <p>WebSocket connection to <code>ws://127.0.0.1:8000/ws/test/</code> </p>
  
  <p>failed: <strong>Error during WebSocket handshake: net::ERR_CONNECTION_RESET</strong></p>
  
  <p>If you need more information, please tell me. </p>