Skip to content

Failed parsing MQTT data on /t_trace as JSON #657

Open

Description

@CunningBard

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

Activity

  1. m-stefanski commented on Dec 25, 2021

    @m-stefanski

    Same

    Python 3.9.1
    fbchat 1.9.7
    
  2. dotSIS commented on Dec 28, 2021

    @dotSIS

    Having the same issue...

    Python 3.9.7
    fbchat 1.9.7

  3. MohamadOday commented on Feb 11, 2022

    @MohamadOday

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions