Это работает на моем локальном хосте. Но при развертывании на AWS ElasticBeanstalk я получаю эту ошибку:
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"]
),
})
Мое соединение JS:
var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws";
var connection = new WebSocket( ws_scheme + "://" + window.location.host + "/socket" + window.location.pathname );
В конфигурации AWS WSGIPath указывает на wsgi.py
. Вроде бы каналы от 2 до urls.py