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.

Django Channels in Production Mode

See original GitHub issue

Hello, I’m trying to integrate a chat in my app with Django Channels, which works in development mode, but doesn’t work in production mode. This is some error I get: Failed to construct ‘WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS. I’ve done the steps presented in the Django Channels documentation(https://channels.readthedocs.io/en/latest/deploying.html), but it doesn’t work for me. When I try to run the daphne start server command 'daphne -p 6379 muypicky.asgi:application ', the console freezes and it does nothing.

Daphne command:

daphne -p 6379 muypicky.asgi:application                                                                                                               
2020-07-21 23:06:43,123 INFO     Starting server at tcp:port=6379:interface=127.0.0.1
2020-07-21 23:06:43,124 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2020-07-21 23:06:43,124 INFO     Configuring endpoint tcp:port=6379:interface=127.0.0.1
2020-07-21 23:06:43,125 INFO     Listening on TCP address 127.0.0.1:6379

I’m not sure where I’m mistaken, any help would be appreciated.

myproject/settings.py

ASGI_APPLICATION = 'muypicky.routing.application'

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            "hosts": [('hradutiu.pythonanywhere.com', 6379)],
        },
    },
}

pip freeze

aioredis==1.3.1
asgiref==3.2.10
async-timeout==3.0.1
attrs==19.3.0
autobahn==20.7.1
Automat==20.2.0
cffi==1.14.0
channels==2.4.0
channels-redis==3.0.1
constantly==15.1.0
cryptography==3.0
daphne==2.5.0
Django==3.0.7
hiredis==1.1.0
hyperlink==19.0.0
idna==2.10
incremental==17.5.0
msgpack==1.0.0
Pillow==7.1.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
pytz==2020.1
redis==3.5.3
service-identity==18.1.0
six==1.15.0
sqlparse==0.3.1
Twisted==20.3.0
txaio==20.4.1
zope.interface==5.1.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
saibhaskar24commented, Jul 23, 2020

@Radutiu-Horatiu . I think pythonanywhere don’t have support for Redis-Server https://www.pythonanywhere.com/forums/topic/12039/ . I have tried most of the cloud services and at last, landed up with a virtual machine to deeply Django channels in production.

Even I tried Redis with other services like an azure Redis catch but it won’t allow running channels in port 6379 in https as this is insecure port. https://stackoverflow.com/questions/62861435/django-channels-and-azure

1reaction
saibhaskar24commented, Jul 23, 2020

@Radutiu-Horatiu I think heroku has support for this as they have some plugin for redis but I didn’t try… According to me going ahead with virtual machine is the best option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying — Channels 4.0.0 documentation
Channels (ASGI) applications deploy similarly to WSGI applications - you load them into a server, like Daphne, and you can scale the number...
Read more >
Django Channels and its production deployment
Introduction · Channels is a project that takes Django and extends its abilities beyond HTTP — to handle WebSockets, chat protocols, IoT ...
Read more >
How can i run Django channels on production? - Stack Overflow
Everything works perfectly, i can see my template loading. I also added a small Django Channels feature, but that part doesn't work; so...
Read more >
Django Channels 2.0 to Production Environment - Blog Post
Learn how to deploy a Django Channels project into production. Entire Project Code. Course: Chat x Channels. Requirements. Django 2.0.5 or ...
Read more >
Introduction to Django Channels - TestDriven.io
Because of the differences between Channels and Django, we'll have to frequently switch between sync and async code execution. For example, the ...
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