Facebook-chat-api: Listen can be run only once for an api instance

Created on 24 Mar 2020  路  10Comments  路  Source: Schmavery/facebook-chat-api

After I upgraded from 1.6.1 to 1.7.0 I am not able to run api.listenMqtt() again for the same api instance. I use login() to create an api instance and then I export this instance and use it in my code to listen for Facebook messages based on specific requests I receive (I have a http.createServer listening for requests and I use these requests to send messages to FB with api.sendMessage()).

After each response from my server, I run stopListening() as I don't wait for any more messages from Facebook. Everything works fine for the first request but when I get a second request api.listenMqtt() is not working.

Most helpful comment

Sure. I'll look into it and do some tests. Thanks for notifying me.
I'll try to make a fix soon.

All 10 comments

I think that these variables should be resetted after stopListening

var identity = function () {};
var mqttClient = undefined;

Any idea of how can I access these variables through the api instance? Thank you in advance

try to modify listenMqtt in your node_modules

Thank you. I tried it but it didn't help :/

I have the same issue with listenMqtt :(
Any idea how this could be resolved?
Thanks in advance

This is a major issue for me too. Please advice.

@7osCraft can we add the mqttClient variable to the API context instead of making it a global variable? sorry I missed this during review

https://github.com/Schmavery/facebook-chat-api/blob/3227d2ef8b8354bcb0f3eab5d293421d4c85f524/index.js#L67-L75

Sure. I'll look into it and do some tests. Thanks for notifying me.
I'll try to make a fix soon.

@7osCraft thank you for looking into it!

Do we have any updates on this?

Hello,
Sorry for the delay, I'll try to get a PR today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thaspoom picture thaspoom  路  5Comments

TKasperczyk picture TKasperczyk  路  5Comments

ezaca picture ezaca  路  3Comments

tomekb530 picture tomekb530  路  6Comments

Alcap picture Alcap  路  7Comments