2

I am very interested in the idea to write a chat application. I've recently come across great tutorial at https://channels.readthedocs.io/en/latest/index.html using DjangoChannels All understood, wrote my own one (suppose the same as there), everything is working. However, I ran into a problem: when updating the chat page, the server throws this exception (and after that I can't send messages, so that's quite harmful):

Exception in callback AsyncioSelectorReactor.callLater.<locals>.run() at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twisted/internet/asyncioreactor.py:287
handle: <TimerHandle when=53.716773429 AsyncioSelectorReactor.callLater.<locals>.run() at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twisted/internet/asyncioreactor.py:287>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twisted/internet/asyncioreactor.py", line 290, in run
    f(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/daphne/server.py", line 229, in application_checker
    exception = application_instance.exception()
asyncio.exceptions.CancelledError

(I am using WebsocketConsumer, python 3.8.2)

Actually, I suppose there is a problem with the disconnection with the server when updating the page. I tried to solve it myself but unfortunately didn't succeed :( Could anybody please help me?

Ahmed I. Elsayed
  • 2,013
  • 2
  • 17
  • 30
  • in your consumer do you have any long running tasks? – Matthaus Woolard Apr 21 '20 at 02:18
  • There is a discussion about this, [here](https://github.com/datadvance/DjangoChannelsGraphqlWs/issues/28). Someone suggested change to Python 3.7, which is a relative easy way to solve the problem if you're using Docker – Genarito Oct 21 '20 at 20:37

1 Answers1

1

I've solved the problem updating my Redis server and dependencies. My final versions are:

  • Python: 3.8.5 or 3.8.6 (both tested)
  • Redis 6.0.8
  • Dependencies:
channels==2.4.0
channels-redis==3.1.0
daphne==2.5.0
Django==3.1.2
django-filter==2.4.0
djangorestframework==3.12.1

There are some issues where a few users offer different solutions: link 1, link 2. Maybe you can find updates about this problem there.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Genarito
  • 3,027
  • 5
  • 27
  • 53