'What is the websocket url of my AWS EC2 Instance?

I have successfully implemented a chat system using Django Channels. I am trying to deploy it to my EC2 Instance. I am reading the official channels documentation and also following other tutorials. Before daemonising daphne and adding a proxy pass. I wanted to run it manually so I ran the following command.

$ daphne -b 0.0.0.0 -p 5000 instagram.asgi:application

INFO     Starting server at tcp:port=5000:interface=0.0.0.0
INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
INFO     Configuring endpoint tcp:port=5000:interface=0.0.0.0
INFO     Listening on TCP address 0.0.0.0:5000
# chat/routing.py
from django.urls import re_path

from . import consumers

websocket_urlpatterns = [
    re_path(r'^ws/chat/(?P<room_name>[\w-]+)/', consumers.ChatConsumer.as_asgi()),
]
#asgi.py
"""
ASGI config for instagram project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
import chat.routing
from instagram.ChatJWTAuth import JWTAuthMiddleware

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

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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source