It works on my localhost. But when I deploy on AWS ElasticBeanstalk, I get this error:
Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
resolver_match = resolver.resolve(request.path_info)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 523, in resolve
raise Resolver404({'tried': tried, 'path': new_path})
django.urls.exceptions.Resolver404: {'tried': [[<URLPattern '^$' [name='home']>], [<URLPattern '^comunidade/'>]], 'path': 'socket/comunidade/'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 99, in get_exception_response
response = callback(request, **dict(param_dict, exception=exception))
TypeError: handler404() got an unexpected keyword argument 'exception'My routing.py:
application = ProtocolTypeRouter({
"websocket": OriginValidator(
AuthMiddlewareStack(
URLRouter([
# URLRouter just takes standard Django path() or url() entries.
path("socket/", MyConsumer),
url("socket/(?P<slug>[\w-]+)", MyConsumer),
]),
),
[".mydomain.com.br", "localhost"]
),
})My JS connection:
var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws";
var connection = new WebSocket( ws_scheme + "://" + window.location.host + "/socket" + window.location.pathname );In AWS config, WSGIPath is pointing to wsgi.py. It seems to be routing channels 2 to urls.py