Skylar-Tech / node-red-contrib-matrix-chat

Matrix chat server support for Node-RED
GNU General Public License v3.0
33 stars 10 forks source link

duplicate messages #30

Closed cthompstone closed 2 years ago

cthompstone commented 2 years ago

Hi anyone know why, after awhile of running I start to get messages coming in on receive nodes duplicated? I presume it must be because the node is somehow using 2 connections back to the matrix server. If I restart node-red the problem goes away (for awhile). It's not really a big deal, I just have to filter them and drop the 2nd message off. However, it's not really how things should be. Thanks

skylord123 commented 2 years ago

I actually used to have this problem with another Node-RED matrix module and it was one of the reasons I created this one. I thought I had fixed the issue but apparently not.

I'm curious if this is an issue in the matrix-js-sdk itself.

Do you know if Node-RED lost connection to the matrix server before this starts happening? I would assume it has to do with the client's auto reconnect functionality.

skylord123 commented 2 years ago

I just did a test on my laptop. I ran node-red locally and had it connect to a matrix server. I then sent a chat message to the bot and it only came in once. I turned my wifi off and waited for the bot to notice it was offline then I reconnected to the wifi and sent another message and it only came in once..

The following questions should help us figure this out: Is there anything in your log that helps explain what is going on? What node-red version are you running? Are you sure you are using node-red-contrib-matrix-chat (which is this module) and not node-red-contrib-matrix (which is the other available matrix client)?

cthompstone commented 2 years ago

You know what, just tried it now and working normally... again... I think I'll have to come back you on this when I notice it happening again. I moved to your node as I thought it would be better (and it's much better in every way, so thanks for the work) Maybe it was just having a moment. We don't have the best internet connection where we live, so I suspect that might not help.

cthompstone commented 2 years ago

Really sorry... AGAIN, think maybe I was reading the logs wrong. Looked through the syslogs for the last 6 days, could not find any duplicates. Your node is so useful, keep up the good work.

skylord123 commented 2 years ago

I just want to update this just-in-case someone else encounters this and stumbles across this thread.

The log for node-red will display a message more than once if you have multiple receive nodes in your palette (you get one log per receive node).

I plan to fix this in the future so that messages coming in are only ever logged once. This is just logging only though. The nodes will only send the message once just as they are intended to do. If you do have a node sending one message multiple times please do re-open this ticket or create another one.