0

Locally, everything works fine. When I deploy the applications to Railway I get a "WebSocket connection to failed" error.

`

application = ProtocolTypeRouter({
    "http": django_asgi_app,
    "websocket": AllowedHostsOriginValidator(AuthMiddlewareStack(URLRouter(chat.routing.websocket_urlpatterns))),
})
websocket_urlpatterns = [
    re_path(r"ws/chat/(?P<room_name>\w+)/$", consumers.ChatConsumer.as_asgi()),
]
const chatSocket = new WebSocket('wss://' + 'appdvibe.up.railway.app' + '/chat/' + roomName + '/');
  • compare version of django and other libraries ( channels if you are using) in local and production, also make sure if configured the webserver ( nginx/apache ) for websocket ( ws location), While moving to production you might need to install some thing like daphe ( or other...) for websocket to work. Please impove your question , Its not clear about you configured webserver, installed daphne , you using django-channels , its versions ... – Jisson Feb 14 '23 at 10:06

0 Answers0