fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Failed parsing MQTT data on /t_trace as JSON

Open CunningBard opened this issue 2 years ago • 3 comments

Description of the problem

on Message received gives out a UnicodeDecodeError

Code to reproduce

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

CunningBard avatar Dec 25 '21 18:12 CunningBard

Same

Python 3.9.1
fbchat 1.9.7

m-stefanski avatar Dec 25 '21 19:12 m-stefanski

Having the same issue...

Python 3.9.7 fbchat 1.9.7

dotSIS avatar Dec 28 '21 00:12 dotSIS

Hey guys, Try using a very old user-agent that may fix it. you can try this one: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

MohamadOday avatar Feb 11 '22 05:02 MohamadOday