title: Websocket with Django channels doesn't work, connection failed
body: <p><strong>Hello Awesome People!</strong></p>
  
  <p>I created a chat room with <code>django-channels</code>. Every time I try to connect to my chat room via web socket in production, it fails.
  Locally it works correctly.</p>
  
  <p>I host on <strong>digitalocean</strong></p>
  
  <p>pip freeze:</p>
  
  <pre><code>channels==2.1.2
  channels-redis==2.3.0
  daphne==2.2.1
  '''
  </code></pre>
  
  <p>I have installed the <code>redis-server</code> with </p>
  
  <pre><code>sudo apt-get install redis-server
  </code></pre>
  
  <p>Here's my settings.</p>
  
  <pre><code>INSTALLED_APPS = [
      # '''
     'channels',
      # '''
  ] 
  CHANNEL_LAYERS = {
      'default': {
          'BACKEND': 'channels_redis.core.RedisChannelLayer',
          'CONFIG': {
              "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
          },
      },
  }
  ASGI_APPLICATION = "project_name.routing.application"
  </code></pre>
  
  <p>Here's my <code>asgi.py</code> alongside <code>wsgi.py</code></p>
  
  <pre><code>import os
  import django
  from channels.routing import get_default_application
  
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings")
  django.setup()
  application = get_default_application()
  </code></pre>
  
  <p>And here's my <code>project_folder.rounting.py</code></p>
  
  <pre><code>application = ProtocolTypeRouter({
      'websocket':AllowedHostsOriginValidator(
          AuthMiddlewareStack(
              URLRouter([
                  # my urls
              ])
          )
      )
  })
  </code></pre>
  
  <p>I keep getting this in firefox and something similar in other browsers:</p>
  
  <blockquote>
    <p>Firefox can’t establish a connection to the server at wss://www.domain_name.com/url-to/1/XBvZjr2pqdf6fhy/</p>
  </blockquote>
  
  <p>However it works locally.</p>
  
  <p>UPDATE</p>
  
  <p>Here is my js</p>
  
  <pre><code>var loc = window.location;
  var wsStart = loc.protocol == "https:" ? "wss://" : "ws://"
  var endpoint = wsStart + loc.host + loc.pathname
  var socket = new ReconnectingWebSocket(endpoint);
  
  socket.onmessage = function(e){
      // code
  }
  </code></pre>