How to configure/debug Python chat application on a production Ubuntu system

I have developed an application using Python and Django. As part of a recent update I have added a chat window. This all worked fine on my development system (Windows 11 using runserver) using both InMemoryChannelLayer and RedisChannelLayer. I am now trying to get a test production server configured correctly. The production environment is Ubuntu running under apache2. So far I have installed: channels, daphne, django-redis, and redis-server. I have added this configuration to /etc/systemd/system/daphne.socket

[Unit]
Description=daphne socket

[Socket]
ListenStream=/run/daphne.sock

[Install]
WantedBy=sockets.target

I have added this configuration to /etc/systemd/system/daphne.service

[Unit]
Description=daphne daemon
Requires=daphne.socket
After=network.target

[Service]
Type=simple
User=root

WorkingDirectory=/home/csrmedical/CSRMedical/medical
ExecStart=/home/csrmedical/venv/bin/daphne -b 0.0.0.0 -p 8000 HouseUponTheRock.asgi:application

[Install]
WantedBy=multi-user.target

My channel layer configuration is

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [(".localhost", 6379),
                ("127.0.0.1", 6379),
                ("[::1]", 6379),
                ("stout", 6379)],
        }
    }
}

and I see redis listening on at [::]:6379 and 0.0.0.0:6379

However when I try to connect to my websocket, I get the error (/ws/chat/ not found, where chat is my group name.

Вернуться на верх