I have followed the channels tutorial but while running these error throw
Version of the packages is channels==2.1.2 Django==2.0.4<
I was also having the same issue i did everything to resolve it, creating another virtual environment and installing older version of Django but after 2 days of hardware i came to realize that my consumers.py file was missing with just a 's' in consumer's' and after that i also corrected in my routing.py file. May be this could be your problem also please do check all the file names first.
In my case it was wrong import in different file.
What you should do is
python manage.py shell
from mysite.routing import application
Look what exact error it produces and try to fix that
Just change
ASGI_APPLICATION = mysite.routing.application
to
ASGI_APPLICATION = "routing.application"
I solved my problem by:
Also check if you have put the routing.py file in the wrong directory. It should be 'myproject/routing.py'
I am also facing the same problem.
Make sure:
=> The routing.py file should be inside the project root folder(i.e. django server, one that has settings.py, wsgi.py,..)
=> In settings.py include, ASGI_APPLICATION = "yourprojectrootname.routing.application"
=>Sometimes, the coding inside routing.py file may generate this error, to check if this is the case remove all the coding and enter the general template coding,
from channels.routing import ProtocolTypeRouter
application = ProtocolTypeRouter({
# Empty for now (http->django views is added by default)
})
then run the 'python manage.py runserver'. This time if you didn't get any error then problem lies in coding inside routing.py. Debug and fix the issue.
=>In other cases this may be of version problem, downgrading to channels==2.1.2 works
Check for any potential errors (maybe import error) in consumers.py. Also, try to put channels as the first item in INSTALLED_APPS in settings.py.
As stated in channels document:
The Channels development server will conflict with any other third-party apps that require an overloaded or replacement runserver command. An example of such a conflict is with whitenoise.runserver_nostatic from whitenoise. In order to solve such issues, try moving channels to the top of your INSTALLED_APPS or remove the offending app altogether.