Closed jensneuhaus closed 7 years ago
Hello, Sorry that I did not answer for a long time. I tried to reproduce this bug, but I can't. Can you give me more information - Python version, channels version and event/data example. Thanks you.
I encounter the same problem.I found it's decoding bug. The code is locate in utils function send_debug. I have been fixed like this.
def send_debug(data, event, group=GROUP_NAME_GROUPS):
from django.utils.encoding import smart_str
Group(group).send({'text': json.dumps({'data': smart_str(data), 'event': event, _MARK: _MARK}, cls=MessageJSONEncoder)})
smart_str
does not fit, because data
is instance of dict, and string format not equal to json format (but it can work). backslashreplace
a more suitable solution. Thanks @jensneuhaus
Thanks for your panel.
I was getting an "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 2: invalid start byte" error. This PR works for me.
I am not sure what the correct solution is for the UTF8, I have chosen
backslashreplace
.Some resources: