WebWhatsapp-Wrapper icon indicating copy to clipboard operation
WebWhatsapp-Wrapper copied to clipboard

Error in function getUnreadMessages (No active session with ID <SESSION_ID>)

Open angmon73 opened this issue 3 years ago • 6 comments

Hello to everyone, I use the WebWhatsapp-Wrapper in an Ubuntu 20.04 server, with python 3.8.10 and using the dockerized version of Selenium for the webdriver. Starting from the last 10 days I have a strange behaviour in my system: every 2 - 3 days, I have the error "Error in function getUnreadMessages (Browsing context has been discarded)" (of course I can see it in the log file). The Firefox web client (with Whatsapp web inside) freezes and the only thing I can do is to shutdown and restart the entire system. Sometimes I tried to shutdown and restart only the whatsapp service, but it didn't work.

Furtherless: during the "normal" running, I can see tens of errors of type "Error: Accessing TypedArray data over Xrays is slow, and forbidden in order to encourage..." in my log file, even thouth I have followed the #1095 Issue suggestions. However it seems that this second problem not affects the normal server operation.

I need help, please Thank you in advance

angmon73 avatar Feb 23 '22 11:02 angmon73

Try to delete waveform data from quotedMessage Code will be like this (after #1095 patch)

.... delete ret.mediaData.waveform if (ret.quotedMsg && ret.quotedMsg.waveform) delete ret.quotedMsg.waveform return ret ....

PS As I understood waveform - is a shit that makes whatsapp message object huge and it blocks normal work

osolodkin avatar Feb 24 '22 20:02 osolodkin

@osolodkin, thank you very much. So, if I understand your suggestion, the complete code shoud be the following, right?

window.WAPI.processMessageObj = function(messageObj, includeMe, includeNotifications) { if (messageObj.isNotification) { if (includeNotifications) { ret = WAPI._serializeMessageObj(messageObj); delete ret.waveform delete ret.mediaData.waveform if (ret.quotedMsg && ret.quotedMsg.waveform) delete ret.quotedMsg.waveform return ret } else { return; } // System message // (i.e. "Messages you send to this chat and calls are now secured with end-to-end encryption...") } else if (messageObj.id.fromMe === false || includeMe) { ret = WAPI._serializeMessageObj(messageObj); delete ret.waveform delete ret.mediaData.waveform if (ret.quotedMsg && ret.quotedMsg.waveform) delete ret.quotedMsg.waveform return ret } return; };

... I'm sorry, but I can't obtain the correct code indentation for the previous function

angmon73 avatar Feb 24 '22 21:02 angmon73

I'm back again... I applied the new patch (as @osolodkin suggested me) to my wapi.js, but nothing happened. At this moment I have no errors in my whatsapp.log file, but I can see a serious time lag in receiveng messages in the whatsapp web "selenium" page. For example, I sent a message from my phone at 11.13 AM and It was received in whatsapp web at 11.33 AM.

Any Idea? Thanks in advance

angmon73 avatar Feb 26 '22 10:02 angmon73

Hi @angmon73 You've wrote correct code. About time lag, guess this is because of Ukraine conflict. Facebook and all services have some problems right now.

Now about the bug. As I got correct, you have Error in function getUnreadMessages not permanently. I think this is because of some kind of messages. My fix resolves only problem when you quote voice message. Try to find out what kind of message (quote, smile, reply, forward message or smth else) you recieve and you will find out how to solve this bug. After this, write me back, I will advice you how to debug this issue.

PS to check my fix try to revert it and quote(reply) any voice message, then put fix back.

osolodkin avatar Feb 26 '22 17:02 osolodkin

Thank you very much @osolodkin. I didn't hear about Facebook services problems for the Ukraine conflict. Maybe it can explain the very large time lag on saturday morning (about twenty minutes between sending and receiving a small text message). I usually receive a lot of messages and they are essentially voice or text messages; just some video and some image. I use webwhatsapp API to receive messages from customers in a broadcasting radio. No sending, just receiving messages from listeners. Because my system receives tens of messages every minute, it's not so easy to understand which of them is the blocking one; however none of them is a reply, because I don't write to listeners; just read from them. Any suggestion about the debugging?

Thank you very much in advance.

angmon73 avatar Feb 27 '22 21:02 angmon73

Case of mine is only with voicemessages, received messages with no quote at all. Shouldn't webwhatsapi clone messages array before process it?

erm3nda avatar Aug 19 '22 17:08 erm3nda