fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

client.listen crashing only on one Facebook Account

Open coreyjansen opened this issue 4 years ago • 2 comments

Description of the problem

I have tried client.listen on 2 facebook accounts. One works no problem, the other was working until just recently and now it is not working. The account it is not working on is a newer account however I have no problems when I login to the browser interface. I would be willing to pass over my credentials for the account that it is not working with to debug

Code to reproduce

# Example code
import configparser
from fbchat import log, Client, Message, Plan
from icalendar import Calendar, Event
from datetime import datetime
import time
from pytz import UTC # timezone
from itertools import islice
import requests
import re
import json
import os


#https://fbchat.readthedocs.io/en/stable/examples.html



dirpath = os.path.dirname(os.path.abspath(__file__))           
#grabs config and calls main function
config = configparser.ConfigParser()
config.read(dirpath+'/configdraft.ini')

cookies = {}
try:
    # Load the session cookies
    with open(dirpath+'/sessiondraft.json', 'r') as f:
        cookies = json.load(f)
except:
    # If it fails, never mind, we'll just login again
    pass

client = Client(config['FACEBOOK']['facebookemail'], config['FACEBOOK']['facebookpassword'],session_cookies=cookies)
with open(dirpath+'/sessiondraft.json', 'w') as f:
    json.dump(client.getSession(), f)

client.listen()



Traceback

Logging in [email protected]...
Login of [email protected] successful.
Traceback (most recent call last):
  File "/mnt/c/Users/Gustin Quon/Documents/Ubuntu/chatbot/draftChatBot.py", line 194, in <module>
    client.listen()
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_client.py", line 2883, in listen
    self.startListening()
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_client.py", line 2835, in startListening
    foreground=True,
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_mqtt.py", line 47, in connect
    sequence_id=cls._fetch_sequence_id(state),
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_mqtt.py", line 132, in _fetch_sequence_id
    (j,) = state._graphql_requests(_graphql.from_doc_id("1349387578499440", params))
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_state.py", line 273, in _graphql_requests
    return self._post("/api/graphqlbatch/", data, as_graphql=True)
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_state.py", line 241, in _post
    return _graphql.response_to_json(content)
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_graphql.py", line 54, in response_to_json
    _util.handle_graphql_errors(value)
  File "/home/corey/.local/lib/python3.6/site-packages/fbchat/_util.py", line 164, in handle_graphql_errors
    fb_error_message=error.get("message"),
fbchat._exception.FBchatFacebookError: GraphQL error #None: Errors while executing operation "MessengerThreadlist": At Query.viewer:Viewer.message_threads:ViewerMessageThreadsConnection.sync_sequence_id: Field implementation threw an exception. Check your server logs for more information. / None

Environment information

  • Python version 3.6.7
  • fbchat version
  • If relevant, output from $ python -m pip list aenum (2.2.3) asn1crypto (0.24.0) attrs (19.3.0) Automat (0.6.0) beautifulsoup4 (4.8.2) blinker (1.4) certifi (2019.11.28) chardet (3.0.4) click (6.7) cloud-init (18.5) colorama (0.3.7) command-not-found (0.3) configobj (5.0.6) configparser (4.0.2) constantly (15.1.0) cryptography (2.1.4) distro-info (0.18ubuntu0.18.04.1) fbchat (1.9.6) httplib2 (0.9.2) hyperlink (17.3.1) icalendar (4.0.4) idna (2.8) incremental (16.10.1) Jinja2 (2.10) jsonpatch (1.16) jsonpointer (1.10) jsonschema (2.6.0) keyring (10.6.0) keyrings.alt (3.0) language-selector (0.1) MarkupSafe (1.0) netifaces (0.10.4) oauthlib (2.0.6) paho-mqtt (1.5.0) PAM (0.4.2) pip (9.0.1) pyasn1 (0.4.2) pyasn1-modules (0.2.1) pycrypto (2.6.1) pygobject (3.26.1) PyJWT (1.5.3) pyOpenSSL (17.5.0) pyserial (3.4) python-apt (1.6.5+ubuntu0.2) python-dateutil (2.8.1) python-debian (0.1.32) pytz (2019.3) pyxdg (0.25) PyYAML (3.12) requests (2.22.0) requests-unixsocket (0.1.5) SecretStorage (2.3.1) service-identity (16.0.0) setuptools (39.0.1) six (1.14.0) soupsieve (1.9.5) ssh-import-id (5.7) systemd-python (234) Twisted (17.9.0) ufw (0.36) unattended-upgrades (0.1) urllib3 (1.25.8) wheel (0.30.0) zope.interface (4.3.2)

If you have done any research, include that. Make sure to redact all personal information.

coreyjansen avatar Jan 23 '20 19:01 coreyjansen

Ended up waiting a while and it worked again but will still leave it open incase it happens again

coreyjansen avatar Jan 23 '20 20:01 coreyjansen

I'll leave this open, it looks like something that would be interesting to investigate!

madsmtm avatar Jan 24 '20 19:01 madsmtm