fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Client.search_for_threads hangs on connecting to the socket for ever

Open saavedra29 opened this issue 4 years ago • 1 comments

Description of the problem

When i try to get threads by name using the Client's search_for_threads method it hangs on connecting to the socket for ever

Code to reproduce

import atexit
import json
import getpass
import fbchat as fb


def load_cookies(filename):
    try:
        # Load cookies from file
        with open(filename) as f:
            return json.load(f)
    except FileNotFoundError:
        return  # No cookies yet


def save_cookies(filename, cookies):
    with open(filename, 'w') as f:
        json.dump(cookies, f)


def load_session(cookies):
    if not cookies:
        return
    try:
        return fb.Session.from_cookies(cookies)
    except fb.FacebookError:
        return  # Failed loading from cookies


cookies = load_cookies('session.json')
session = load_session(cookies)
if not session:
    # Session could not be loaded, login instead!
    session = fb.Session.login('myemail.com', getpass.getpass())

client = fb.Client(session=session)
threads = list(client.search_for_threads('the_group_to_search', limit=5))

Traceback

When i interrupt with the keyboard after a minute of waiting the last lines i get are

~/.virtualenvs/fbchat/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     72             if source_address:
     73                 sock.bind(source_address)
---> 74             sock.connect(sa)
     75             return sock
     76 

Environment information

  • Python version 3.8
  • fbchat version 2.0.0a2

saavedra29 avatar May 17 '20 20:05 saavedra29

Thanks for the report. This is probably related to https://github.com/carpedm20/fbchat/issues/573, so I'll track our progress in that issue

madsmtm avatar Jun 07 '20 12:06 madsmtm