问题
I am developing an app using Django,I have deployed it on Google Cloud Platform initially using WSGI environment,now I have made addition in app and used channels due to which I have to shift from WSGI to ASGI, but I am getting errors while deploying to Google Cloud Platform when I use ASGI environment
I got the error: respiter = self.wsgi(environ, resp.start_response) TypeError: __call__() takes 2 positional arguments but 3 were given
I commented the all content of WSGI file when I want to use ASGI environmnet,here's me related code:
ASGI FILE:
import os
import django
from channels.routing import get_default_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Frames.settings')
django.setup()
application = get_default_application()
WSGI FILE (which I have commented):
"""
WSGI config for Frames project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Frames.settings')
application = get_wsgi_application()"""
main.py:
from Frames.asgi import application
app = application
Settings.py(Main changes and I have removed all WSGI related from settings.py)
ASGI_APPLICATION = "Frames.routing.application"
CHANNEL_LAYERS={
"default":{
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("localhost", 6379)],
},
},
}
How can I run ASGI environment? If I missed something in showing my code I can also show that,I can't get what the problem is,Is my way of deploying ASGI app is correct?
回答1:
App Engine Standard currently does not support ASGI.
To work with ASGI you should use App Engine Flexible, where you can tweak the environment much further.
Then, you might find useful the guide in the GAE flex documentation about Creating Persistent Connections with WebSockets.
来源:https://stackoverflow.com/questions/59527805/problem-in-running-asgi-environments-while-deploying-app-django-rest