fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

Get 'for (;;); {"t":"refresh","reason":110,"seq":0}' when pull message #45

Closed blcc closed 7 years ago

blcc commented 8 years ago

Hi,

After smoothly use for few days, I found fbchat stop pull new message. When the _pullMessage in listen function return content, it actually return following string:

'for (;;); {"t":"refresh","reason":110,"seq":0}'

It may be mean reload page is required in browser, but have no idea how to do in requests session.

Thanks.

bsansouci commented 8 years ago

Hey @blcc, I work on the nodejs version of this API and we've potentially had a similar problem. The simplest solution would be to simply make a request to www.facebook.com and make sure to save all the new cookies it sends back, and then go back to listening. If you try, tell us if it works :)

lobstr commented 8 years ago

Have this same error. Just started playing around with _pullMessage and added "clientid" to the data that gets sent to the sticky URL and it started working okay. I don't really know what clientid is, just copied it and it's value from my browser, but hopefully that sheds some light for someone more inclined.

blcc commented 8 years ago

@lobstr is right. The "clientid" may be used as identification of browser/apps. Which maybe generated by javascript in FB home randomly. So that @bsansouci's method also does the magic. In fact there is client_id variable in client.py. Hence all we need to do is insert following to line 405 of fbchat/client.py: "clientid": self.client_id, Remember the indent, it is the dict "data" in _pullMessage() function.

Thanks guys.