fbchat-dev / fbchat-dev/fbchat

Failed parsing MQTT data on /t_trace as JSON

Open
#657 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1.2k
Forks
403
PR merge metrics
No merged PRs in 30d

Description

## Description of the problem
on Message received gives out a UnicodeDecodeError

## Code to reproduce
```py
from Essential.esen import email, password
from fbchat.models import *
import fbchat
import json

class Client(fbchat.Client):
def onMessage(self, mid=None, author_id=None, message=None, message_object=None, thread_id=None,
thread_type=ThreadType.USER, ts=None, metadata=None, msg=None):
message_text = message_object.text
print(message_text)

def main():
with open("session.json") as f:
cookies = json.load(f)

client = Client(email, password, session_cookies=cookies)
client.startListening()
for _ in range(100):
client.doOneListen()
print(_ + 1)

client.stopListening()

if __name__ == '__main__':
main()

```

## Traceback
```
24
hello
25
Failed parsing MQTT data on /t_trace as JSON
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\_mqtt.py", line 77, in _on_message_handler
j = _util.parse_json(message.payload.decode("utf-8"))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 3: invalid continuation byte
26
Messages seen by 10007000000000 in 10007000000000 (USER) at 1640458300.433s
27
29
```

## Environment information
- Python 3.6.8
- `fbchat 1.9.7` version

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.