0

I am deploying my Django app on AWS Ec2 with Apache. I have Asgi and WSGI. I wanna run:

sudo daphne MyProject.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2
sudo python manage.py runworker -v2

But when I run the worker I am getting

Running worker for channels ['channels']
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.8/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.8/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.8/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.8/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/channels/management/commands/runworker.py", line 46, in handle
    worker.run()
  File "/usr/lib/python3.8/asgiref/server.py", line 59, in run
    event_loop = get_running_loop()
RuntimeError: no running event loop

I found this solution: Daphne + Channel v3 Deployment, RuntimeError: no running event loop but I already have asgiref==3.3.4

1-I found this one on github: https://github.com/django/asgiref/issues/278 but did not really understand how should I solve it. 2-I also did not really understand what should I do in Apache to filter the websocket request from the Normal request.

If anyone has the same problem and know how to do it I would really appreciate it. Cause I don't have any Idea how to solve it.

1 Answers1

0

I just solved it by deleting asgerif. somehow I had 2 versions of asgerif installed and after deleting it it worked fine.