Open Alcap opened 4 years ago
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
I'm also experiencing this issue – my listen handler is no longer receiving messages.
There was a Messenger outage yesterday; perhaps this is related?
Facebook Messenger is using WebSocket now.
great, now we need to rewrite that listen.js
file
I have the same issue too. I think they now use websockets only.
I think they are using a MQTT over websockets protocol.
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
I have the same issue too.
I also have the same issue.
If anyone has time, they could experiment with hooking up something like https://www.npmjs.com/package/mqtt maybe
@Schmavery Actually I did. It worked but the library itself needs some modification to work with the facebook protocol.
I'll try to get a PR ready when I can.
Stopped working today
for now i think that this could work as a replacement until the issue is resolved
PR is ready. Waiting to be merged.
@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.
@KMatuszak do an npm install ac-opensource/facebook-chat-api
for now, I fixed it on mine
Listen is still not working for me, even with @ac-opensource's fix.
For me it works after @ac-opensource fix, but it looks like listenMqtt is listening by default for everything, not only for messages.
@KMatuszak yeah sorry will fix that
Issue fixed. Yes, listenMqtt listens for everything that listen was polling.
@KMatuszak Please tell me if you find any errors.
@AstroCB is there any logs you could provide?
Everything works fine now for me :slightly_smiling_face:
@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.
Shouldn't we just replace the listen function with mqtt?
The .listen() is obsolete anyway now and they work basically in the same way.
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***' ]
@7osCraft Maybe merge not yet. How to use this?
@KMatuszak Yes it's actually faster. Before mqtt it was polling facebook servers at some rate which I think the maximum is 250ms. But now with the mqtt protocol it's faster because you're just waiting for messages from the server and the connection is always open and no polling/requesting is happening.
@PixelHir I didn't change any other function so mqtt changes shouldn't affect getUserInfo. I'll test to see if facebook changed something.
@seakBz
npm install 7osCraft/facebook-chat-api
Working perfectly for me now!
@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)
@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
@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.
@KMatuszak Pushed an update. Could you please try now?
Yup, but i need some time to make sure the error will not occur again.
Now it spams JSON's in the console 😛
Yeah that was a mistake I need to fix it
@KMatuszak All good now please install again and sorry for that
Now everything is working perfectly, thank you 🙂
@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?
@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
@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?
yey no more err spam and bot run faster! ty! 👍
listenMqtt
works great so far, however events (message.type === "event"
) are not picked up.
@kentnek Make sure listenEvents is set to true in the options.
@7osCraft it's always been true
in my code. Below is my setup:
api.setOptions({
logLevel: "warn",
listenEvents: true,
forceLogin: true
});
For some reason, this happens
Not sure why it happened, the code was running in background
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
For some reason, this happens
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
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!