Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Daphne server does not spin up automatically with channels=4.x #1068

Open
ckrew opened this issue Jul 17, 2024 · 4 comments
Open

[BUG] Daphne server does not spin up automatically with channels=4.x #1068

ckrew opened this issue Jul 17, 2024 · 4 comments

Comments

@ckrew
Copy link
Contributor

ckrew commented Jul 17, 2024

Describe the bug
When using a consumer class is used to create a websocket, the daphne server does not spin up on the "tethys manage start" command and therefore a websocket is never created. The outputs from the "tethys manage start" command show "Starting development server at http://127.0.0.1:8000/"

To Reproduce
Steps to reproduce the behavior:

  1. Create a consumer class
  2. Run "tethys manage start"

Expected behavior
I would expect a daphne server to spin up and have a message like "Starting ASGI/Daphne version 4.1.2 development server at http://127.0.0.1:8000/".

Tethys Environment Information
channels=4.x

@ckrew ckrew added the bug label Jul 17, 2024
@ckrew
Copy link
Contributor Author

ckrew commented Jul 17, 2024

According to the django channel 4.0.0 release notes, daphne is now decoupled from channels. If users want to run daphne with runserver, then daphne must be added to the installed apps explicitly in the settings.

INSTALLED_APPS = [ "daphne", ... ]

@swainn swainn modified the milestones: Version 4.3, Version 5.0 Jul 19, 2024
@sdc50
Copy link
Member

sdc50 commented Aug 23, 2024

According to the django channel 4.0.0 release notes, daphne is now decoupled from channels. If users want to run daphne with runserver, then daphne must be added to the installed apps explicitly in the settings.

INSTALLED_APPS = [ "daphne", ... ]

I've been playing around with this for bokeh-django and ran into this error:

ERRORS:
?: (daphne.E001) Daphne must be listed before django.contrib.staticfiles in INSTALLED_APPS.

This is a pretty easy fix if you have access to the settings.py file, but with Tethys we limit modifying the settings to the portal_config.yml file. Currently all INSTALLED_APPS in the portal_config.yml will be appended to the default list in the tethys_portal/settings.py file. The only way around this currently is to use the INSTALLED_APPS_OVERRIDE setting, but that requires that users know and list all of the default apps that are needed.

I'm planning to test adding daphne as an installed app in Tethys. My hope is that it will not change anything for versions of daphne<4, while "just working" with daphne=4.

@sdc50
Copy link
Member

sdc50 commented Aug 23, 2024

On a related note, since channels=4.x is decoupled from daphne it depends on daphne=4.x. Using channels=4 with daphne=3 will not work.

However, when I try to install an unpinned version of django and channels from conda-forge it resolves to:

  + channels              4.0.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + daphne                3.0.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + django                  5.1  pyhd8ed1ab_0        conda-forge/noarch        Cached

Which is a bit strange since channels=4 requires daphne=4, and if you try to pin channels=4 and django=5 it errors out (see below).

$ mamba create -n django-channels django channels

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.0.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['django', 'channels']

conda-forge/osx-arm64                                       Using cache
conda-forge/noarch                                          Using cache
Transaction

  Prefix: /Users/rditlsc9/conda/envs/django-channels

  Updating specs:

   - django
   - channels


  Package               Version  Build               Channel                     Size
───────────────────────────────────────────────────────────────────────────────────────
  Install:
───────────────────────────────────────────────────────────────────────────────────────

  + appdirs               1.4.4  pyh9f0ad1d_0        conda-forge/noarch        Cached
  + asgiref               3.8.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + attrs                24.2.0  pyh71513ae_0        conda-forge/noarch        Cached
  + autobahn             24.4.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + automat              24.8.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + bcrypt                4.2.0  py312h552d48e_0     conda-forge/osx-arm64     Cached
  + bzip2                 1.0.8  h99b78c6_7          conda-forge/osx-arm64     Cached
  + ca-certificates    2024.7.4  hf0a4a13_0          conda-forge/osx-arm64     Cached
  + cffi                 1.17.0  py312h80c9ed6_0     conda-forge/osx-arm64     Cached
  + channels              4.0.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + constantly           15.1.0  py_0                conda-forge/noarch        Cached
  + cryptography         43.0.0  py312had01cb0_0     conda-forge/osx-arm64     Cached
  + daphne                3.0.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + django                  5.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + hyperlink            21.0.0  pyhd3deb0d_0        conda-forge/noarch        Cached
  + idna                    3.7  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + incremental          24.7.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + libexpat              2.6.2  hebf3989_0          conda-forge/osx-arm64     Cached
  + libffi                3.4.2  h3422bc3_5          conda-forge/osx-arm64     Cached
  + libsqlite            3.46.0  hfb93653_0          conda-forge/osx-arm64     Cached
  + libzlib               1.3.1  hfb2fe0b_1          conda-forge/osx-arm64     Cached
  + ncurses                 6.5  hb89a1cb_0          conda-forge/osx-arm64     Cached
  + openssl               3.3.1  h8359307_3          conda-forge/osx-arm64     Cached
  + pip                    24.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyasn1                0.6.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyasn1-modules        0.4.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pycparser              2.22  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyopenssl            24.2.1  pyhd8ed1ab_2        conda-forge/noarch        Cached
  + python               3.12.5  h30c5eda_0_cpython  conda-forge/osx-arm64     Cached
  + python_abi             3.12  5_cp312             conda-forge/osx-arm64     Cached
  + readline                8.2  h92ec313_1          conda-forge/osx-arm64     Cached
  + service-identity     24.1.0  pyha770c72_0        conda-forge/noarch        Cached
  + service_identity     24.1.0  hd8ed1ab_0          conda-forge/noarch        Cached
  + setuptools           72.2.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + six                  1.16.0  pyh6c4a22f_0        conda-forge/noarch        Cached
  + sqlparse              0.5.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + tk                   8.6.13  h5083fa2_1          conda-forge/osx-arm64     Cached
  + twisted              24.7.0  py312h7e5086c_0     conda-forge/osx-arm64     Cached
  + txaio                23.1.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + typing-extensions    4.12.2  hd8ed1ab_0          conda-forge/noarch        Cached
  + typing_extensions    4.12.2  pyha770c72_0        conda-forge/noarch        Cached
  + tzdata                2024a  h0c530f3_0          conda-forge/noarch        Cached
  + wheel                0.44.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + xz                    5.2.6  h57fd34a_0          conda-forge/osx-arm64     Cached
  + zope.interface        7.0.1  py312h7e5086c_0     conda-forge/osx-arm64     Cached

  Summary:

  Install: 45 packages

By specifying daphne=4 it forces django to 4.2:

$ mamba create -n django-channels django channels daphne=4

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.0.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['django', 'channels', 'daphne=4']

conda-forge/noarch                                            No change
conda-forge/osx-arm64                                         No change
Transaction

  Prefix: /Users/rditlsc9/conda/envs/django-channels

  Updating specs:

   - django
   - channels
   - daphne=4


  Package                Version  Build               Channel                     Size
────────────────────────────────────────────────────────────────────────────────────────
  Install:
────────────────────────────────────────────────────────────────────────────────────────

  + appdirs                1.4.4  pyh9f0ad1d_0        conda-forge/noarch        Cached
  + asgiref                3.8.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + attrs                 24.2.0  pyh71513ae_0        conda-forge/noarch        Cached
  + autobahn              24.4.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + automat               24.8.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + backports.zoneinfo     0.2.1  py312h81bd7bf_8     conda-forge/osx-arm64     Cached
  + bcrypt                 4.2.0  py312h552d48e_0     conda-forge/osx-arm64     Cached
  + bzip2                  1.0.8  h99b78c6_7          conda-forge/osx-arm64     Cached
  + ca-certificates     2024.7.4  hf0a4a13_0          conda-forge/osx-arm64     Cached
  + cffi                  1.17.0  py312h80c9ed6_0     conda-forge/osx-arm64     Cached
  + channels               4.1.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + constantly            15.1.0  py_0                conda-forge/noarch        Cached
  + cryptography          43.0.0  py312had01cb0_0     conda-forge/osx-arm64     Cached
  + daphne                 4.1.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + django                4.2.15  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + hyperlink             21.0.0  pyhd3deb0d_0        conda-forge/noarch        Cached
  + idna                     3.7  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + incremental           24.7.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + libexpat               2.6.2  hebf3989_0          conda-forge/osx-arm64     Cached
  + libffi                 3.4.2  h3422bc3_5          conda-forge/osx-arm64     Cached
  + libsqlite             3.46.0  hfb93653_0          conda-forge/osx-arm64     Cached
  + libzlib                1.3.1  hfb2fe0b_1          conda-forge/osx-arm64     Cached
  + ncurses                  6.5  hb89a1cb_0          conda-forge/osx-arm64     Cached
  + openssl                3.3.1  h8359307_3          conda-forge/osx-arm64     Cached
  + pip                     24.2  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyasn1                 0.6.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyasn1-modules         0.4.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pycparser               2.22  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + pyopenssl             24.2.1  pyhd8ed1ab_2        conda-forge/noarch        Cached
  + python                3.12.5  h30c5eda_0_cpython  conda-forge/osx-arm64     Cached
  + python_abi              3.12  5_cp312             conda-forge/osx-arm64     Cached
  + readline                 8.2  h92ec313_1          conda-forge/osx-arm64     Cached
  + service-identity      24.1.0  pyha770c72_0        conda-forge/noarch        Cached
  + service_identity      24.1.0  hd8ed1ab_0          conda-forge/noarch        Cached
  + setuptools            72.2.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + six                   1.16.0  pyh6c4a22f_0        conda-forge/noarch        Cached
  + sqlparse               0.5.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + tk                    8.6.13  h5083fa2_1          conda-forge/osx-arm64     Cached
  + twisted               24.7.0  py312h7e5086c_0     conda-forge/osx-arm64     Cached
  + txaio                 23.1.1  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + typing-extensions     4.12.2  hd8ed1ab_0          conda-forge/noarch        Cached
  + typing_extensions     4.12.2  pyha770c72_0        conda-forge/noarch        Cached
  + tzdata                 2024a  h0c530f3_0          conda-forge/noarch        Cached
  + wheel                 0.44.0  pyhd8ed1ab_0        conda-forge/noarch        Cached
  + xz                     5.2.6  h57fd34a_0          conda-forge/osx-arm64     Cached
  + zope.interface         7.0.1  py312h7e5086c_0     conda-forge/osx-arm64     Cached

  Summary:

  Install: 46 packages

Trying to force django=5, channels=4.1, and daphne=4 results in:

$ mamba create -n django-channels django=5 channels=4.1 daphne=4

...

Encountered problems while solving:
  - package channels-4.1.0-pyhd8ed1ab_0 requires django >=3.2,<5, but none of the providers can be installed

This appears to be a bug in the conda packaging since the pyproject.toml for channels=4.1 specifies:

install_requires =
    Django>=4.2
    asgiref>=3.6.0,<4

@sdc50
Copy link
Member

sdc50 commented Aug 23, 2024

The mismatch in how conda resolves the versions should be fixed with:

conda-forge/channels-feedstock#17

and

conda-forge/channels-feedstock#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants