Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed parsing MQTT data on /t_trace as JSON #657

Open
CunningBard opened this issue Dec 25, 2021 · 3 comments
Open

Failed parsing MQTT data on /t_trace as JSON #657

CunningBard opened this issue Dec 25, 2021 · 3 comments

Comments

@CunningBard
Copy link

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
@m-stefanski
Copy link

Same

Python 3.9.1
fbchat 1.9.7

@dotSIS
Copy link

dotSIS commented Dec 28, 2021

Having the same issue...

Python 3.9.7
fbchat 1.9.7

@MohamadOday
Copy link

MohamadOday commented Feb 11, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants