Project

General

Profile

Plugins are not receiving all the messages

Luca Stucchi
Added almost 4 years ago

Hi there,

I am experiencing a strange thing: in a situation with 2 users logged in tigase, admin@mydomain.net and username@sub.mydomain.net*, I have a plugin registered to get all the *message stanzas.

Somehow, the Session Manager forwards a message only to the plugin whose session is associated to the stanza TO user.

I developed this plugin before the release of the version 7 of Tigase, and I was able to intercept messages checking if the session was associated to the Jid in the From with the code pasted here below:

session.isUserId(fromJid)

Does this say anything to you ? It looks like there was a change in how the SM forwards the packets to the plugins. Is this possible ? Was this expected ?

In my understanding, the SM should forward the message to any of the plugins registered for a particular stanza (message) and for all the logged users, is this correct or I misunderstood something ?

Thanks in advance,

Luca


Replies (11)

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

Luca Stucchi wrote:

Does this say anything to you ? It looks like there was a change in how the SM forwards the packets to the plugins. Is this possible ? Was this expected ?

In my understanding, the SM should forward the message to any of the plugins registered for a particular stanza (message) and for all the logged users, is this correct or I misunderstood something ?

API hasn't changed and your understanding is correct. Are you sure you're sending exactly the same stanza (check both supported elements and XML namespaces!).

Added by Luca Stucchi almost 4 years ago

Hi Wojciech,

what I am doing is sending a message from admin to user, and both are online.

I performed some further test and I found out something new: the in a scenario in which a message is sent from admin to a user, and the user answers back that he received the message, the original message is not captured by the plugin associated with the "admin" session, but it is captured by the plugin associated with the "user" session.

The received message is captured as expected by both admin and user, and so all the other messages going back and forth.

Below I copied some log that I made the plugin write to understand a little better the situation. As you can see the very first message is intercepted by the plugin associated with the user user only.

The other different thing is that that message is the only having an AMP extension. Could this prevent it to be sent to the plugin in association with the admin user session ?

2015-05-19 10:05:03.584 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from admin@domain.net to user@sub.domain.net in session for user user[from=amp@domain.net, to=sess-man@domain.net,                                       DATA=<message id="353081897" from="admin@domain.net/Server-1" xmlns="jabber:client" to="user@sub.domain.net/Smack">... , SIZE=1231, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=null]

2015-05-19 10:05:03.925 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from user@sub.domain.net to admin@domain.net in session for user user[from=c2s@domain.net/172.31.18.86_5222_2.218.202.101_61390, to=sess-man@domain.net, DATA=<message to="admin@domain.net/Server-1" from="user@sub.domain.net/Smack" xmlns="jabber:client" id="j5WOe-51"><received xmlns="urn:xmpp:receipts" id="353081897"/></message>, SIZE=192, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=null]
2015-05-19 10:05:03.927 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from user@sub.domain.net to admin@domain.net in session for user admin[from=sess-man@domain.net, to=sess-man@domain.net,                                 DATA=<message to="admin@domain.net/Server-1" from="user@sub.domain.net/Smack" xmlns="jabber:client" id="j5WOe-51"><received xmlns="urn:xmpp:receipts" id="353081897"/></message>, SIZE=192, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=null]

2015-05-19 10:32:12.814 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from user@sub.domain.net to admin@domain.net in session for user user[from=c2s@domain.net/172.31.18.86_5222_2.218.202.101_61390, to=sess-man@domain.net, DATA=<message to="admin@domain.net/Server-1" from="user@sub.domain.net/Smack" xmlns="jabber:client" id="j5WOe-60"><body>555009652</body><request xmlns="urn:xmpp:receipts"/></message>, SIZE=198, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=null]
2015-05-19 10:32:12.816 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from user@sub.domain.net to admin@domain.net in session for user admin[from=sess-man@domain.net, to=sess-man@domain.net,                                 DATA=<message to="admin@domain.net/Server-1" from="user@sub.domain.net/Smack" xmlns="jabber:client" id="j5WOe-60"><body>555009652</body><request xmlns="urn:xmpp:receipts"/></message>, SIZE=198, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=null]

2015-05-19 10:32:12.888 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from admin@domain.net to user@sub.domain.net in session for user admin[from=c2s@domain.net/172.31.18.86_5222_2.218.202.101_6862, to=sess-man@domain.net, DATA=<message id="s7471-133" from="admin@domain.net/Server-1" xmlns="jabber:client" type="normal" to="user@sub.domain.net/Smack"><received xmlns="urn:xmpp:receipts" id="j5WOe-60"/></message>, SIZE=206, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=normal]
2015-05-19 10:32:12.890 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from admin@domain.net to user@sub.domain.net in session for user user[from=sess-man@domain.net, to=sess-man@domain.net,                                  DATA=<message id="s7471-133" from="admin@domain.net/Server-1" xmlns="jabber:client" type="normal" to="user@sub.domain.net/Smack"><received xmlns="urn:xmpp:receipts" id="j5WOe-60"/></message>, SIZE=206, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=normal]

Do you see any reason for this message to behave in a different way ? Is maybe AMP interfering with the process ?

Thanks in advance,

Luca

Added by Luca Stucchi almost 4 years ago

Just to integrate the information, if I send a message without AMP, the plugin works as expected:

2015-05-20 08:18:02.146 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from admin@domain.net to user@sub.domain.net in session for user admin[from=c2s@domain.net/172.31.18.86_5222_2.228.102.101_47566, to=sess-man@domain.net, DATA=<message to="user@sub.domain.net" id="ac3fa" from="admin@domain.net/Server-1" xmlns="jabber:client">
2015-05-20 08:18:02.148 [Validity Queue Worker 0]  MyPlugin.process()   SEVERE:   I am processing a packet from admin@domain.net to user@sub.domain.net in session for user user[from=sess-man@domain.net, to=sess-man@domain.net,                                   DATA=<message to="user@sub.domain.net" id="ac3fa" from="admin@domain.net/Server-1" xmlns="jabber:client">

Maybe this further information can help you in finding out if something is going wrong

All the best

Luca

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

OK, one note - in first case packet is user[from=amp@domain.net, to=sess-man@domain.net, - note the from - it's from AMP component so it looks, that for some reason the packet was forwarded to AMP component.

Added by Luca Stucchi almost 4 years ago

Well OK, but I send the message directly from admin@ to user@. Not that I want to find someone or something to blame, but could this be a problem in amp message handling ?

Or you see any reason for this to happen ? No message is sent directly to amp component, and from what you write, this is not an expected behavior.

Does this make any sense to you / rings any bell ?

All the best,

Luca

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam almost 4 years ago

There was a change in how packets are processed in Tigase XMPP Server in 7.x release in which SessionManager preprocesses messages and if it finds AMP rules then it forwards this stanzas for processing by AMP component.

So in first case user[from=amp@domain.net, to=sess-man@domain.net, this entry is correct as most propably SessionManager forwarded packet to AMP component for processing and now you received response from AMP component after processing.

Added by Luca Stucchi almost 4 years ago

Oh my ! This is what I was most fearing... thanks for the clue !

But now I have a problem: I need to forward that message to a component: I was sure that the admin@ was always online, so I made a plugin to intercept the message and forward it to the component.

How can I implement the same behavior now ? if the recipient will not be online (and it is most likely) the packet won't be processed at all... what would you suggest ?

Thanks in advance,

Luca

Added by Natale Vinto almost 4 years ago

Hi Andrzej,

is there any update on this? I'm also blocked on Tigase 7.1 for this structural change

Regards,

Natale

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam almost 4 years ago

I created ticket #3131 for this issue and will work on providing proper solution to this issue as outgoing messages with AMP should be processed in scope of session of user who sent message.

Added by Luca Stucchi almost 4 years ago

Wonderful ! Thanks for your sunday patch ! Now plugins are correctly triggered and everything looks to be fine !

Thank you so much !

Have a nice day,

Luca

Added by Natale Vinto almost 4 years ago

Thanks Andrzej,

everything's fine also over here :)

Regards,

Natale

    (1-11/11)