0

I use django channels and get this exception when receive message:

2017-07-27 08:34:56,241 - DEBUG - worker - Got message on websocket.receive (reply daphne.response.key)
2017-07-27 08:34:56,242 - DEBUG - runworker - websocket.receive
2017-07-27 08:34:56,242 - DEBUG - worker - Dispatching message on websocket.receive to project.consumers.ws_message
Traceback (most recent call last):
  File "/project/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/channels/management/commands/runworker.py", line 83, in handle
    worker.run()
  File "/usr/local/lib/python2.7/dist-packages/channels/worker.py", line 151, in run
    consumer_finished.send(sender=self.__class__)
  File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python2.7/dist-packages/channels/message.py", line 105, in send_and_flush
    sender.send(message, immediately=True)
  File "/usr/local/lib/python2.7/dist-packages/channels/channel.py", line 88, in send
    self.channel_layer.send_group(self.name, content)
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/core.py", line 130, in send_group
    for channel in self.group_channels(group):
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/core.py", line 137, in group_channels
    return self.group_store.flush_expired(group)
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/store.py", line 188, in flush_expired
    for item, expiry in value[name].items()
KeyError: u'None'
2017-07-27 08:34:57,719 - INFO - runworker - Using single-threaded worker.
2017-07-27 08:34:57,719 - INFO - runworker - Running worker against channel layer default (asgi_ipc.core.IPCChannelLayer)
2017-07-27 08:34:57,719 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive

ws_message code:

@channel_session
def ws_message(message):
    order_id = int(message.content['text'])
    order = Order.objects.get(pk=order_id)

    artist_id = message.channel_session["user_id"]
    artist = Artist.objects.get(user=User.objects.get(pk=artist_id))

    order.artist = artist

    Group(str(order.client.id)).send({'bytes': json.dumps({'time': str(order.time),
                                                           'name': artist.user.first_name + " " + artist.user.last_name})})

What am I doing wrong?

1 Answers1

0

A str(order.client.id) is 'None'?

Seems like asgi_ipc bug on flushing expired groups. Look at actual sources of asgi_ipc for flush_expired

In asgi_ipc sources must be test - if name in value on flush_expired

1) Try update channels and asgi_ipc 2) Report issue for asgi_ipc

estin
  • 3,051
  • 1
  • 24
  • 31