Tuesday, September 4, 2018

Channels 2 on AWS Elastic Beanstalk

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82b5bb8e-7722-42ee-9a32-0553ab6d6f87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment