fbchat-dev / fbchat-dev/fbchat

Client.search_for_threads hangs on connecting to the socket for ever

Open
#577 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.2k
Forks
403
PR merge metrics
No merged PRs in 30d

Description

## 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
```py
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.