question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multiple daphne processes with supervisord and UNIX socket

See original GitHub issue

Setup daphne with supervisord and nginx as shown in the docs is working. https://channels.readthedocs.io/en/latest/deploying.html#nginx-supervisor-ubuntu

But changing from TCP to UNIX socket for the fcgi process group results in daphne not responding to requests.

Run as single program in supervisor

[program:current.example.com_daphne]
command = /srv/current.example.com/env/bin/daphne --unix-socket /srv/current.example.com/run/daphne.sock --proxy-headers crm.asgi:application
directory = /srv/current.example.com/src/
environment = LANGUAGE=en_US.UTF-8,LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,PYTHONPATH='/srv/current.example.com/env/'
user = www-data

Request

root@crm:# curl -v --no-buffer --unix-socket /srv/current.example.com/run/daphne.sock "http://current.example.com/dashboard/"
*   Trying /srv/current.example.com/run/daphne.sock...
* Connected to current.example.com (/srv/current.example.com/run/daphne.sock) port 80 (#0)
> GET /dashboard/ HTTP/1.1
> Host: current.example.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /auth/login/?next=/dashboard/
< X-Frame-Options: SAMEORIGIN
< Vary: Accept-Language, Cookie
< Content-Language: de
< Content-Length: 0
< 
* Connection #0 to host current.example.com left intact

Run as fcgi-program in supervisor

[fcgi-program:demo.example.com_daphne]
command = /srv/demo.example.com/env/bin/daphne --fd 0 --proxy-headers crm.asgi:application
directory = /srv/demo.example.com/src/
environment = LANGUAGE=en_US.UTF-8,LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,PYTHONPATH='/srv/demo.example.com/env/'
user = www-data
socket=unix:///srv/demo.example.com/run/daphne.sock
numprocs = 2

Request

root@crm:# curl -v --no-buffer --unix-socket /srv/demo.example.com/run/daphne.sock "http://demo.example.com/dashboard/"
*   Trying /srv/demo.example.com/run/daphne.sock...
* Connected to demo.example.com (/srv/demo.example.com/run/daphne.sock) port 80 (#0)
> GET /dashboard/ HTTP/1.1
> Host: demo.example.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
* Recv failure: Connection reset by peer
* stopped the pause stream!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
stephendwolffcommented, Jul 9, 2020

I finally fixed my websocket connection. I discovered Ubuntu18.04 standard apt repositories provide redis v4, and Channels Redis requires >=v5.

1reaction
stephendwolffcommented, Jul 9, 2020

@carltongibson thanks - it is in the Channels Redis docs, but i hadn’t thought to look there until i got logging fully working and found where thing broke! The Redis docs recommend installing from source, which i hadn’t done, as i was using Ansible for deployment and it was easier just to use apt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Can you configure Supervisor + multiple Daphne ...
I'm trying to configure the following setup: Django w/ channels; Multiple Daphne processes as the ASGI server, with ssl endpoints ...
Read more >
Channels: development issue with multiple daphne workers
I am trying to migrate a tornado project to django channel2. I have moved all essential parts and wired them up in channel....
Read more >
Deploying — Channels 4.0.0 documentation
The Channels project maintains an official ASGI HTTP/WebSocket server, Daphne, ... You should run Daphne inside either a process supervisor (systemd, ...
Read more >
Unable to get Django Channels Daphne Nginx Supervisor ...
I am not using Gunicorn. I just can't get it to work, server side processes are not my forte so if someone with...
Read more >
Configuring ASGI Django Application using Daphne and ...
Daphne is a HTTP, HTTP2 and WebSocket protocol server for ASGI ... In order to daemonize this process, I used systemd process supervisor....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found