Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Listen issues #763

Open
Alcap opened this issue Nov 17, 2019 · 57 comments
Open

Listen issues #763

Alcap opened this issue Nov 17, 2019 · 57 comments

Comments

@Alcap
Copy link

Alcap commented Nov 17, 2019

Hi,

Did anyone notice some change in behaviour on facebook's end? I have an api.listen on my code and it was working just fine and all of the sudden it stopped.

Any code that that I place in the callback doesn't get executed when a message is received. This code was working fine just a few days ago and now, nothing.
There's no errors provided, so I'm at a loss on how to go on the troubleshooting and how to fix this.

Thanks!

@Alcap
Copy link
Author

Alcap commented Nov 18, 2019

Actually, I've tried to pick up the example code and run it as vanilla as possible and it is still unable to react when someone sends a message to any thread.
I've looked up how to increase verbosity of the listen functions, but couldn't find anything of relevance... Any tips?

Thanks

@AstroCB
Copy link
Contributor

AstroCB commented Nov 19, 2019

I'm also experiencing this issue – my listen handler is no longer receiving messages.

There was a Messenger outage yesterday; perhaps this is related?

@BadAimWeeb
Copy link
Contributor

Facebook Messenger is using WebSocket now.
image
great, now we need to rewrite that listen.js file

@HossamMohsen7
Copy link
Contributor

HossamMohsen7 commented Nov 20, 2019

I have the same issue too. I think they now use websockets only.

I think they are using a MQTT over websockets protocol.

@HossamMohsen7
Copy link
Contributor

This might help too: https://github.com/tulir/fbchat-asyncio/blob/yet-another-rewrite/fbchat/_client.py#L2749-L2882

@ccfiel
Copy link

ccfiel commented Nov 21, 2019

This might help too: https://github.com/tulir/fbchat-asyncio/blob/yet-another-rewrite/fbchat/_client.py#L2749-L2882

I did try this one but still the same problem

@dinhphuc
Copy link

I have the same issue too.

@ghost
Copy link

ghost commented Nov 24, 2019

I also have the same issue.

@Schmavery
Copy link
Owner

If anyone has time, they could experiment with hooking up something like https://www.npmjs.com/package/mqtt maybe

@HossamMohsen7
Copy link
Contributor

@Schmavery
Actually I did. It worked but the library itself needs some modification to work with the facebook protocol.

@HossamMohsen7
Copy link
Contributor

I'll try to get a PR ready when I can.

@PixelHir
Copy link

Stopped working today

@PixelHir
Copy link

PixelHir commented Nov 27, 2019

for now i think that this could work as a replacement until the issue is resolved

@HossamMohsen7
Copy link
Contributor

PR is ready. Waiting to be merged.

@ghost
Copy link

ghost commented Nov 28, 2019

@7osCraft I have this error on login:

ReferenceError: defaultFuncs is not defined
    at Object.listenMqtt (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\facebook-chat-api\src\listenMqtt.js:413:3)
    at C:\Users\Administrator\Downloads\messenger-bot-node\index.js:107:9
    at C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\facebook-chat-api\index.js:446:14
    at tryCatcher (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\promise.js:510:31)
    at Promise._settlePromiseAt (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\promise.js:584:18)
    at Async._drainQueue (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\async.js:128:12)
    at Async._drainQueues (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

And listening doesn't work. This error is not showing on API from @Schmavery repo using the same code.

@ac-opensource
Copy link

@KMatuszak do an npm install ac-opensource/facebook-chat-api for now, I fixed it on mine

@AstroCB
Copy link
Contributor

AstroCB commented Nov 28, 2019

Listen is still not working for me, even with @ac-opensource's fix.

@ghost
Copy link

ghost commented Nov 28, 2019

For me it works after @ac-opensource fix, but it looks like listenMqtt is listening by default for everything, not only for messages.

@HossamMohsen7
Copy link
Contributor

@KMatuszak yeah sorry will fix that

@HossamMohsen7
Copy link
Contributor

Issue fixed.
Yes, listenMqtt listens for everything that listen was polling.

@HossamMohsen7
Copy link
Contributor

@KMatuszak Please tell me if you find any errors.

@HossamMohsen7
Copy link
Contributor

@AstroCB is there any logs you could provide?

@ghost
Copy link

ghost commented Nov 28, 2019

Everything works fine now for me 🙂

@ghost
Copy link

ghost commented Nov 28, 2019

@7osCraft Out of curiosity, I will ask if these changes related to MQTT can have any effect on the speed of message capture? After these changes my bot responds much faster.

@PixelHir
Copy link

Shouldn't we just replace the listen function with mqtt?

The .listen() is obsolete anyway now and they work basically in the same way.

@PixelHir
Copy link

Shouldn't we just replace the listen function with mqtt?

The .listen() is obsolete anyway now and they work basically in the same way.

I actually take that back, .getUserInfo() now only returns an array of ids i submitted

[ '100010956664***', '100015763590***', '100017030117***', '100036272225***', '100028694583***', '100011812170***', '100022199253***', '100027434141***', '100009891793***', '100012392437***' ]

@dinhphuc
Copy link

@7osCraft Maybe merge not yet. How to use this?

@PixelHir
Copy link

@PixelHir I didn't change any other function so mqtt changes shouldn't affect getUserInfo. I'll test to see if facebook changed something.

I think that facebook is sending data in a different way now, I can try inspecting it later

@HossamMohsen7
Copy link
Contributor

@7osCraft After a few hours of running my bot I got this error:

C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\facebook-chat-api\src\listenMqtt.js:223
                                                delta.deltaMessageReply.repliedToMessage.data === undefined ? [] :
                                                                                         ^

TypeError: Cannot read property 'data' of undefined
    at parseDelta (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\facebook-chat-api\src\listenMqtt.js:223:48)
    at MqttClient.<anonymous> (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\facebook-chat-api\src\listenMqtt.js:91:5)
    at MqttClient.emit (events.js:210:5)
    at MqttClient._handlePublish (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\lib\client.js:1162:12)
    at MqttClient._handlePacket (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\lib\client.js:351:12)
    at work (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\lib\client.js:283:12)
    at Writable.writable._write (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\lib\client.js:294:5)
    at doWrite (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\node_modules\readable-stream\lib\_stream_writable.js:428:64)
    at writeOrBuffer (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\node_modules\readable-stream\lib\_stream_writable.js:417:5)
    at Writable.write (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\mqtt\node_modules\readable-stream\lib\_stream_writable.js:334:11)
    at Duplexify.ondata (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:619:20)
    at Duplexify.emit (events.js:210:5)
    at addChunk (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:291:12)
    at readableAddChunk (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:278:11)
    at Duplexify.Readable.push (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:245:10)
    at Duplexify._forward (C:\Users\Administrator\Downloads\messenger-bot-node\node_modules\duplexify\index.js:170:26)

@KMatuszak
I think that happened to me once in the old polling system. Will push and update right now.

@HossamMohsen7
Copy link
Contributor

@KMatuszak Pushed an update. Could you please try now?

@ghost
Copy link

ghost commented Nov 28, 2019

Yup, but i need some time to make sure the error will not occur again.

@ghost
Copy link

ghost commented Nov 28, 2019

Now it spams JSON's in the console 😛

@HossamMohsen7
Copy link
Contributor

Yeah that was a mistake I need to fix it

@HossamMohsen7
Copy link
Contributor

@KMatuszak All good now please install again and sorry for that

@ghost
Copy link

ghost commented Nov 28, 2019

Now everything is working perfectly, thank you 🙂

@thanhdatpd
Copy link

thanhdatpd commented Nov 29, 2019

@7osCraft
Hi, after run listenMqtt about 2 hour or early, it throw an error:
ERR! Error: Connection refused: Server unavailable
then all devices session expired (facebook/messager app,web) and need login again. I just run some time and not sure when it crash, did you face it?
I will use log silly to see more and post here for error.
Sorry, my English so bad :((

Edit 1: i trying run until now is 4 hour without any error, why?

@Tanuki33
Copy link

@seakBz
npm install 7osCraft/facebook-chat-api

i use this, and this hapend

ERR! markAsRead   error: 1357031,
ERR! markAsRead   errorSummary: 'This content is no longer available',
ERR! markAsRead   errorDescription: 'The content you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may have expired or you may not have permission to view this page.',
ERR! markAsRead   payload: null,
ERR! markAsRead   bootloadable: {},
ERR! markAsRead   ixData: {},
ERR! markAsRead   bxData: {},
ERR! markAsRead   gkxData: {},
ERR! markAsRead   qexData: {},
ERR! markAsRead   lid: '6764586712811045864' }
{ __ar: 1,
  error: 1357031,
  errorSummary: 'This content is no longer available',
  errorDescription: 'The content you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may have expired or you may not have permission to view this page.',
  payload: null,
  bootloadable: {},
  ixData: {},
  bxData: {},
  gkxData: {},
  qexData: {},
  lid: '6764586712811045864' }

but the bot working fine

@PixelHir
Copy link

@seakBz
npm install 7osCraft/facebook-chat-api

i use this, and this hapend

ERR! markAsRead   error: 1357031,
ERR! markAsRead   errorSummary: 'This content is no longer available',
ERR! markAsRead   errorDescription: 'The content you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may have expired or you may not have permission to view this page.',
ERR! markAsRead   payload: null,
ERR! markAsRead   bootloadable: {},
ERR! markAsRead   ixData: {},
ERR! markAsRead   bxData: {},
ERR! markAsRead   gkxData: {},
ERR! markAsRead   qexData: {},
ERR! markAsRead   lid: '6764586712811045864' }
{ __ar: 1,
  error: 1357031,
  errorSummary: 'This content is no longer available',
  errorDescription: 'The content you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may have expired or you may not have permission to view this page.',
  payload: null,
  bootloadable: {},
  ixData: {},
  bxData: {},
  gkxData: {},
  qexData: {},
  lid: '6764586712811045864' }

but the bot working fine

This message shows up when youre accessing something that Facebook doesnt allow you to
Can you try removing the markAsRead function?

@Tanuki33
Copy link

yey no more err spam and bot run faster! ty! 👍

@kentnek
Copy link

kentnek commented Dec 2, 2019

listenMqtt works great so far, however events (message.type === "event") are not picked up.

@HossamMohsen7
Copy link
Contributor

@kentnek Make sure listenEvents is set to true in the options.

@kentnek
Copy link

kentnek commented Dec 2, 2019

@7osCraft it's always been true in my code. Below is my setup:

api.setOptions({
  logLevel: "warn",   
  listenEvents: true,
  forceLogin: true
});

@PixelHir
Copy link

PixelHir commented Dec 3, 2019

For some reason, this happens
Screenshot_20191203-091118

Not sure why it happened, the code was running in background

@Tanuki33
Copy link

Tanuki33 commented Dec 3, 2019

EDIT : i reinstall 7osCraft/facebook-chat-api , work again..
I just realized today, handleMessageRequest not working.

      api.getThreadList(1000, null, ["PENDING"], (err, list) => {
        if (err) return console.error(err.errorSummary);
        for (var prop in list) {
          if (list.hasOwnProperty(prop)) {
            api.handleMessageRequest(list[prop].threadID, true, err => {
              console.log(err);
            });
            console.log("is grup? = " + list[prop].isGroup +"\n" + list[prop].name + "\nCannot Reply? = " + list[prop].cannotReplyReason;
            );
          }
        }

no error output

@Tanuki33
Copy link

Tanuki33 commented Dec 3, 2019

For some reason, this happens
Screenshot_20191203-091118

Not sure why it happened, the code was running in background

i got this to when use changenickname (on my case)
try to reinstall 7osCraft/facebook-chat-api module

@PixelHir
Copy link

PixelHir commented Dec 6, 2019

The pull has been merged already if some of you didn't notice. (#765)

The issue should be still open so we can report any new bugs with Mqtt.

@kentnek
Copy link

kentnek commented Dec 8, 2019

UPDATE: nevermind, it turned out I need to update my fb account's password.

getting new error upon login now:

info login Logged in
info login Request to reconnect
info login Request to pull 1
info login Request to pull 2
info login Request to thread_sync
info login Done logging in.
ERR! getSeqId TypeError: Cannot read property 'error_results' of undefined
ERR! getSeqId     at D:\Libraries\Programming\Web\fb-chatbot\node_modules\facebook-chat-api\src\listenMqtt.js:435:51
ERR! getSeqId     at tryCatcher (D:\Libraries\Programming\Web\fb-chatbot\node_modules\bluebird\js\main\util.js:26:23)
ERR! getSeqId     at Promise._settlePromiseFromHandler (D:\Libraries\Programming\Web\fb-chatbot\node_modules\bluebird\js\main\promise.js:510:31)
ERR! getSeqId     at Promise._settlePromiseAt (D:\Libraries\Programming\Web\fb-chatbot\node_modules\bluebird\js\main\promise.js:584:18)
ERR! getSeqId     at Promise._settlePromises (D:\Libraries\Programming\Web\fb-chatbot\node_modules\bluebird\js\main\promise.js:700:14)

@PixelHir
Copy link

This just happened out of nowhere

ERR! forcedFetch TypeError: Cannot read property 'author' of undefined
ERR! forcedFetch     at /app/node_modules/facebook-chat-api/src/listenMqtt.js:366:32
ERR! forcedFetch     at tryCatcher (/app/node_modules/bluebird/js/main/util.js:26:23)
ERR! forcedFetch     at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/main/promise.js:510:31)
ERR! forcedFetch     at Promise._settlePromiseAt (/app/node_modules/bluebird/js/main/promise.js:584:18)
ERR! forcedFetch     at Promise._settlePromises (/app/node_modules/bluebird/js/main/promise.js:700:14)
ERR! forcedFetch     at Async._drainQueue (/app/node_modules/bluebird/js/main/async.js:123:16)
ERR! forcedFetch     at Async._drainQueues (/app/node_modules/bluebird/js/main/async.js:133:10)
ERR! forcedFetch     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/main/async.js:15:14)
ERR! forcedFetch     at processImmediate (internal/timers.js:439:21)
ERR! forcedFetch     at process.topLevelDomainCallback (domain.js:130:23)
ERR! forcedFetch  TypeError: Cannot read property 'author' of undefined
ERR! forcedFetch     at /app/node_modules/facebook-chat-api/src/listenMqtt.js:366:32
ERR! forcedFetch     at tryCatcher (/app/node_modules/bluebird/js/main/util.js:26:23)
ERR! forcedFetch     at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/main/promise.js:510:31)
ERR! forcedFetch     at Promise._settlePromiseAt (/app/node_modules/bluebird/js/main/promise.js:584:18)
ERR! forcedFetch     at Promise._settlePromises (/app/node_modules/bluebird/js/main/promise.js:700:14)
ERR! forcedFetch     at Async._drainQueue (/app/node_modules/bluebird/js/main/async.js:123:16)
ERR! forcedFetch     at Async._drainQueues (/app/node_modules/bluebird/js/main/async.js:133:10)
ERR! forcedFetch     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/main/async.js:15:14)
ERR! forcedFetch     at processImmediate (internal/timers.js:439:21)
ERR! forcedFetch     at process.topLevelDomainCallback (domain.js:130:23)

@HossamMohsen7
Copy link
Contributor

@PixelHir It's weird now that some fields change in the data that facebook sends. I'll look into that as soon as I can.

@tienchung123
Copy link

Page on MQTT is not working yet.

@ptrcnull
Copy link
Contributor

I'll be more than happy to help on MQTT code, we've been working on Android MQTT version for some time and compared to that, the browser one seems much easier.

@hong4rc
Copy link
Contributor

hong4rc commented Mar 3, 2020

Currently, the listen method has different from the browser.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests