talira

HTTP, HTTP/2 and WebSocket server for ASGI apps, built to power Django Channels

open sourceBSD-3-Clauseself-hostablefree

Daphne is an HTTP, HTTP/2 and WebSocket protocol server for ASGI and ASGI-HTTP applications, developed to power Django Channels and maintained as part of the Channels project under the Django Software Foundation. It negotiates protocols automatically, so WebSocket and HTTP endpoints need no URL prefixes. It can bind to a port, a UNIX socket or a file descriptor from a process manager, takes Twisted endpoint strings for TLS and other bindings, terminates HTTP/2 natively with Twisted's http2 and tls extras, and supports a root path like WSGI's SCRIPT_NAME.

Problems it solves

  • serve my Django Channels app with WebSockets
  • run a Django ASGI app behind nginx over a UNIX socket
  • terminate HTTP/2 for my Python ASGI app

Features

  • HTTP, HTTP/2 and WebSocket server for ASGI apps
  • automatic protocol negotiation, with no URL prefixes for WebSockets
  • binds to ports, UNIX sockets or inherited file descriptors
  • Twisted endpoint strings for TLS and custom bindings
  • root path setting like WSGI's SCRIPT_NAME

Limitations

  • HTTP/2 covers normal requests only, with no Server Push1
  • Needs Python 3.10 or later1

Alternatives

The same job

These do what Daphne does.

  1. Uvicorn ASGI web server for Python with HTTP/1.1, HTTP/2 and WebSockets
  2. Hypercorn ASGI and WSGI web server for Python with HTTP/2, WebSockets and optional HTTP/3
  3. Gunicorn Python WSGI HTTP server for UNIX

Compare Daphne with the top 3