title: Server running with daphne starts to response with code 504 on any http request after passing uncertain time
body: <p>I'm using django-channels2+daphne in production.
  After uncertain time passed I got this error twice (after 2 and after 6 hours correspondingly), which involved <code>504</code> answer on any HTTP request. I have no idea how should I debug the problem. Using nginx, django-channels2, daphne. </p>
  
  <pre><code>Application instance &lt;Task pending coro=&lt;AsgiHandler.__call__() running at /usr/local/lib/python3.7/site-packages/channels/http.py:202&gt; wait_for=&lt;Future pending cb=[_chain_future.&lt;locals&gt;._call_check_cancel() at /usr/local/lib/python3.7/asyncio/futures.py:348, &lt;TaskWakeupMethWrapper object at 0x7ff116ef9708&gt;()]&gt;&gt; for connection &lt;WebRequest at 0x7ff116a86d30 method=GET uri=/api/v1/feed/?page_size=10&amp;distance=-1000&amp;not_reviewed=1 clientproto=HTTP/1.1&gt; took too long to shut down and was killed
  </code></pre>
  
  <p>Here is my nginx config:</p>
  
  <pre><code>server {
      server_name www.example.com example.com;
      return 301 https://example.com$request_uri;
  }
  
  server {
      server_name www.lvh.me lvh.me;
      return 301 https://lvh.me$request_uri;
  }
  
  server {
      listen 443 ssl;
      ssl_certificate /etc/ssl/certs/server.crt;
      ssl_certificate_key /etc/ssl/private/server.key;
      server_name www.example.com;
      return 301 https://example.com$request_uri;
  }
  
  server {
      listen 443 ssl;
      ssl_certificate /etc/ssl/certs/server.crt;
      ssl_certificate_key /etc/ssl/private/server.key;
      server_name www.lvh.me;
      return 301 https://lvh.me$request_uri;
  }
  
  server {
      server_name example.com lvh.me;
      charset UTF-8;
      listen 443 ssl;
  
      ssl_certificate /etc/ssl/certs/server.crt;
      ssl_certificate_key /etc/ssl/private/server.key;
  
      access_log  /var/log/nginx/mini.access.log;
      error_log /var/log/nginx/mini.error.log;
  
      location /static/ {
          autoindex on;
          root /data/django;
      }
  
      location /media/ {
          autoindex on;
          root /data/django;
      }
  
      location / {
          proxy_pass http://django:8000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
  
          proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Host $server_name;
          proxy_set_header X-Forwarded-Proto $scheme;
      }
  }
  </code></pre>
  
  <p>Starting daphne.com with:</p>
  
  <pre><code>daphne -b 0.0.0.0 -p 8000 project.asgi:application
  </code></pre>