{"id":13396916,"url":"https://github.com/django/daphne","last_synced_at":"2025-05-14T08:05:03.324Z","repository":{"id":37735016,"uuid":"48501841","full_name":"django/daphne","owner":"django","description":"Django Channels HTTP/WebSocket server","archived":false,"fork":false,"pushed_at":"2025-04-18T13:58:39.000Z","size":535,"stargazers_count":2500,"open_issues_count":37,"forks_count":275,"subscribers_count":47,"default_branch":"main","last_synced_at":"2025-05-07T07:11:12.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/django.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-12-23T17:06:46.000Z","updated_at":"2025-05-06T11:44:47.000Z","dependencies_parsed_at":"2023-02-19T19:35:30.120Z","dependency_job_id":"18550dd5-ef72-4453-93ce-432e985e62a9","html_url":"https://github.com/django/daphne","commit_stats":{"total_commits":404,"total_committers":72,"mean_commits":5.611111111111111,"dds":"0.43811881188118806","last_synced_commit":"862ebcd08dcd9f392e9603a880fb00a6e710f3b6"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django%2Fdaphne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django%2Fdaphne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django%2Fdaphne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django%2Fdaphne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/django","download_url":"https://codeload.github.com/django/daphne/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101586,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:01:07.600Z","updated_at":"2025-05-14T08:05:03.302Z","avatar_url":"https://github.com/django.png","language":"Python","readme":"daphne\n======\n\n.. image:: https://img.shields.io/pypi/v/daphne.svg\n    :target: https://pypi.python.org/pypi/daphne\n\nDaphne is a HTTP, HTTP2 and WebSocket protocol server for\n`ASGI \u003chttps://github.com/django/asgiref/blob/main/specs/asgi.rst\u003e`_ and\n`ASGI-HTTP \u003chttps://github.com/django/asgiref/blob/main/specs/www.rst\u003e`_,\ndeveloped to power Django Channels.\n\nIt supports automatic negotiation of protocols; there's no need for URL\nprefixing to determine WebSocket endpoints versus HTTP endpoints.\n\n\nRunning\n-------\n\nSimply point Daphne to your ASGI application, and optionally\nset a bind address and port (defaults to localhost, port 8000)::\n\n    daphne -b 0.0.0.0 -p 8001 django_project.asgi:application\n\nIf you intend to run daphne behind a proxy server you can use UNIX\nsockets to communicate between the two::\n\n    daphne -u /tmp/daphne.sock django_project.asgi:application\n\nIf daphne is being run inside a process manager, you might\nwant it to bind to a file descriptor passed down from a parent process.\nTo achieve this you can use the --fd flag::\n\n    daphne --fd 5 django_project.asgi:application\n\nIf you want more control over the port/socket bindings you can fall back to\nusing `twisted's endpoint description strings\n\u003chttp://twistedmatrix.com/documents/current/api/twisted.internet.endpoints.html#serverFromString\u003e`_\nby using the `--endpoint (-e)` flag, which can be used multiple times.\nThis line would start a SSL server on port 443, assuming that `key.pem` and `crt.pem`\nexist in the current directory (requires pyopenssl to be installed)::\n\n    daphne -e ssl:443:privateKey=key.pem:certKey=crt.pem django_project.asgi:application\n\nEndpoints even let you use the ``txacme`` endpoint syntax to get automatic certificates\nfrom Let's Encrypt, which you can read more about at http://txacme.readthedocs.io/en/stable/.\n\nTo see all available command line options run daphne with the ``-h`` flag.\n\n\nHTTP/2 Support\n--------------\n\nDaphne supports terminating HTTP/2 connections natively. You'll\nneed to do a couple of things to get it working, though. First, you need to\nmake sure you install the Twisted ``http2`` and ``tls`` extras::\n\n    pip install -U \"Twisted[tls,http2]\"\n\nNext, because all current browsers only support HTTP/2 when using TLS, you will\nneed to start Daphne with TLS turned on, which can be done using the Twisted endpoint syntax::\n\n    daphne -e ssl:443:privateKey=key.pem:certKey=crt.pem django_project.asgi:application\n\nAlternatively, you can use the ``txacme`` endpoint syntax or anything else that\nenables TLS under the hood.\n\nYou will also need to be on a system that has **OpenSSL 1.0.2 or greater**; if you are\nusing Ubuntu, this means you need at least Ubuntu 16.04.\n\nNow, when you start up Daphne, it should tell you this in the log::\n\n    2017-03-18 19:14:02,741 INFO     Starting server at ssl:port=8000:privateKey=privkey.pem:certKey=cert.pem, channel layer django_project.asgi:channel_layer.\n    2017-03-18 19:14:02,742 INFO     HTTP/2 support enabled\n\nThen, connect with a browser that supports HTTP/2, and everything should be\nworking. It's often hard to tell that HTTP/2 is working, as the log Daphne gives you\nwill be identical (it's HTTP, after all), and most browsers don't make it obvious\nin their network inspector windows. There are browser extensions that will let\nyou know clearly if it's working or not.\n\nDaphne only supports \"normal\" requests over HTTP/2 at this time; there is not\nyet support for extended features like Server Push. It will, however, result in\nmuch faster connections and lower overheads.\n\nIf you have a reverse proxy in front of your site to serve static files or\nsimilar, HTTP/2 will only work if that proxy understands and passes through the\nconnection correctly.\n\n\nRoot Path (SCRIPT_NAME)\n-----------------------\n\nIn order to set the root path for Daphne, which is the equivalent of the\nWSGI ``SCRIPT_NAME`` setting, you have two options:\n\n* Pass a header value ``Daphne-Root-Path``, with the desired root path as a\n  URLencoded ASCII value. This header will not be passed down to applications.\n\n* Set the ``--root-path`` commandline option with the desired root path as a\n  URLencoded ASCII value.\n\nThe header takes precedence if both are set. As with ``SCRIPT_ALIAS``, the value\nshould start with a slash, but not end with one; for example::\n\n    daphne --root-path=/forum django_project.asgi:application\n\n\nPython Support\n--------------\n\nDaphne requires Python 3.9 or later.\n\n\nContributing\n------------\n\nPlease refer to the\n`main Channels contributing docs \u003chttps://github.com/django/channels/blob/main/CONTRIBUTING.rst\u003e`_.\n\nTo run tests, make sure you have installed the ``tests`` extra with the package::\n\n    cd daphne/\n    pip install -e '.[tests]'\n    pytest\n\n\nMaintenance and Security\n------------------------\n\nTo report security issues, please contact security@djangoproject.com. For GPG\nsignatures and more security process information, see\nhttps://docs.djangoproject.com/en/dev/internals/security/.\n\nTo report bugs or request new features, please open a new GitHub issue.\n\nThis repository is part of the Channels project. For the shepherd and maintenance team, please see the\n`main Channels readme \u003chttps://github.com/django/channels/blob/main/README.rst\u003e`_.\n","funding_links":[],"categories":["ASGI Servers","Python","资源列表","HarmonyOS","Http servers","ASGI Servers [🔝](#readme)","ASGI服务器","ASGI 服务器","Websocket Utilities","Async \u0026 Real-Time","Web Frameworks \u0026 RESTful API"],"sub_categories":["ASGI 服务器","Windows Manager","More","ASGI Servers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjango%2Fdaphne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjango%2Fdaphne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjango%2Fdaphne/lists"}