0

I'm unable to deploy asgi django on heroku. Build is successful but it shows Application Error after deployment.

Procfile:

web: daphne quickmeals.asgi:application --port $PORT --bind 0.0.0.0 -v2
worker: python manage.py runworker channel_layers --settings=quickmeals.settings -v2

aspi.py

import os

import django
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 
'quickmeals.settings')

from quickmeals.routing import ws_patterns
from channels.auth import AuthMiddlewareStack


application = ProtocolTypeRouter(
{   'http':get_asgi_application(),
    'websocket': AuthMiddlewareStack( URLRouter(ws_patterns)

) } )

Routing.py

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from . import consumers

ws_patterns = [
path('test',consumers.TestConsumer.as_asgi()),
path('orderUpdate/<str:id>',consumers.orderUpdate.as_asgi()),
path('<str:uid>',consumers.OrderProgress.as_asgi())
]

Settings.py

ASGI_APPLICATION = 'quickmeals.asgi.application'
CHANNEL_LAYERS = {
"default": {
    "BACKEND": "channels_redis.core.RedisChannelLayer",
    "CONFIG": {
        "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
    },
},

}

Also i've no add-ons on heroku.

Please help me out how can i deploy it on heroku. Your any advice would be highly appreciable. Thank you in advance

  • And "application error" is [HTTP 500](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_Error), a generic server-side error message. On its own it doesn't tell us anything useful. Any time you see this your first step should be to check your error logs for more detail. On Heroku, start by running `heroku logs` (the error page should also tell you to do this). – ChrisGPT was on strike Dec 04 '21 at 20:03
  • @Chris i've uploaded the code snippets. also the build is successful, but the problem still persists. Though when i run it on wsgi it works fine. but not with daphne asgi. – Shivam Vats Dec 04 '21 at 20:28
  • Great, thanks! Please also add the logs you see when you run `heroku logs`. We need to know what errors you're getting. – ChrisGPT was on strike Dec 04 '21 at 20:29
  • @Chris i thought heroku logs and build logs were same thing. I ran heroku logs and installed some modules. Now i've successfully deployed the website. Thank you so much for saving my time, and energy much respect. – Shivam Vats Dec 05 '21 at 00:08
  • I'm glad you got it figured out. As the name suggests, build logs are generated at build time. `heroku logs` shows your _runtime_ logs, for messages generated as your application runs. – ChrisGPT was on strike Dec 05 '21 at 04:28

0 Answers0