2

I'm trying to install a production server for Django Channels application I've been running locally with success. However, when starting Daphne and reaching to the application via browser, I get an Internal Server Error from Daphne. Console output is as follows:

2021-08-07 11:57:09,584 DEBUG    HTTP b'GET' request for ['127.0.0.1', 33566]
2021-08-07 11:57:10,071 ERROR    Exception inside application: 'module' object is not callable
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/asgiref/compatibility.py", line 34, in new_application
    instance = application(scope)
TypeError: 'module' object is not callable
2021-08-07 11:57:10,072 DEBUG    HTTP 500 response started for ['127.0.0.1', 33566]

As the project/asgi.py might have some relevance here, it is below:

import os
import django
from django.core.asgi import get_asgi_application

os.environ['DJANGO_SETTINGS_MODULE'] = "proj.settings"
django.setup()

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import app.routing

application = ProtocolTypeRouter({
  "http": get_asgi_application(),
  "websocket": AuthMiddlewareStack(
        URLRouter(
            app.routing.websocket_urlpatterns
        )
    ),
})

However, I've been poking around with the said asgi.py, and I have a feeling that at least the application variable does not have anything to do with this, as that block could be commented out with no impact on the error message.

Relevant packages:

channels              3.0.4
daphne                3.0.2
Django                3.2.6

Any ideas?

Uitto
  • 31
  • 3
  • Do you use django-configurations library by a chance? Your issue is very like this one, maybe it's worth checking https://stackoverflow.com/questions/49480976/django-channels-daphne-internal-server-error-dict-object-is-not-callable – Nikita Tonkoskur Aug 07 '21 at 21:39
  • Nope, no django-configurations in use. Also, I removed all additional middleware, for testing purposes, but no luck. – Uitto Aug 08 '21 at 08:29

0 Answers0