title: Deploy django-channels with Apache2 and Daphne
body: <p>I'm trying to learn to use <code>django-channels</code> and have worked through both the tutorial and <a href="https://github.com/andrewgodwin/channels-examples/tree/master/multichat" rel="noreferrer">this multichat example</a>.  I am now trying to deploy it on a Digital Ocean droplet using Apache and Daphne.  I would happily use Daphne by itself but I do not understand how to.</p>
  
  <p>So this is my Apache conf file:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin webmaster@mysite.co.uk
      ServerName multichat.mysite.co.uk
      ServerAlias www.multichat.mysite.co.uk
      DocumentRoot /var/www/multichat
      WSGIDaemonProcess multichat python-path=/var/www/multichat python-home=/var/www/multichat/env
      WSGIProcessGroup multichat
      WSGIScriptAlias / /var/www/multichat/multichat/wsgi.py
  
      Alias /robots.txt /var/www/multichat/static/robots.txt
      Alias /favicon.ico /var/www/multichat/static/favicon.ico
  
      Alias /media/ /var/www/multichat/media/
      Alias /static/ /var/www/multichat/static/
  
      &lt;Directory /var/www/multichat/static&gt;
          Require all granted
      &lt;/Directory&gt;
  
      &lt;Directory /var/www/multichat/media&gt;
          Require all granted
      &lt;/Directory&gt;
  
      WSGIScriptAlias / /var/www/multichat/multichat/wsgi.py
  
      &lt;Directory /var/www/multichat/multichat&gt;
          &lt;Files wsgi.py&gt;
              Require all granted
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I've installed Redis and have it up and running.  </p>
  
  <p>I've included this file in <code>/etc/systemd/system/daphne.service</code></p>
  
  <pre><code>[Unit]
  Description=daphne daemon for multichat
  After=network.target
  
  [Service]
  User=root
  Group=www-data
  WorkingDirectory=/var/www/multichat/multichat
  ExecStart=/var/www/multichat/env/bin/daphne -b 0.0.0.0 -p 8001 multichat.asgi:application
  
  # Not sure if should use 'on-failure' or 'always'. 
  Restart=on-failure
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Although the webpage comes up and I can login etc, when it comes to a chatroom I have the following error in console:</p>
  
  <blockquote>
    <p>WebSocket connection to 'ws://multichat.mysite.co.uk/chat/stream/'
    failed: Error during WebSocket handshake: Unexpected response code:
    404</p>
  </blockquote>
  
  <p>I'm clearly not setting up something correctly but I don't know where to turn.  I would happily scrape Apache if I can get a pointer on how to use just Daphne, but I've tried and got nowhere with that either</p>