Project

General

Profile

How to send command to SessionManager from custom component?

Taras Panchak
Added over 1 year ago

Hello!

We configured in init.properties:

sess-man/command/ALL[S]=ALL
sess-man/admins[s]=admin@jabber.dev.net, client1@jabber.dev.net, customComponent@jabber.dev.net

And sending stanza:

<iq type="set" to="sess-man@jabber.dev.net" id="1234">
    <command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#get-online-users-list">
        <x xmlns="jabber:x:data" type="submit">
            <field type="hidden" var="FORM_TYPE">
                <value>http://jabber.org/protocol/admin</value>
            </field>
            <field type="list-single" var="domainjid">
                <value>jabber.dev.net</value>
            </field>
            <field type="list-single" var="max_items">
                <value>None</value>
            </field>
        </x>
    </command>
</iq>

It works for client1@jabber.dev.net -> returns:

<iq to='client1@jabber.dev.net/1647699466-tigase-1' id='1234' from='sess-man@jabber.dev.net' type='result'>
    <command xmlns='http://jabber.org/protocol/commands' status='completed' node='http://jabber.org/protocol/admin#get-online-users-list'>
        <x xmlns='jabber:x:data' type='result'>
            <field type='text-multi' var='Users: 2'>
                <value>client1@jabber.dev.net (1:1647699466-tigase-1)</value>
                <value>admin@jabber.dev.net (1:myComp)</value>
            </field>
        </x>
    </command>
</iq>

But it doesn't work in case then send this stanza from custom component (deployed on Tigase) -> from logs:

[in_21-sess-man]   SessionManager.processPacket()     FINEST:   Received packet: from=null, to=null, DATA=<iq from="customComponent@myDomain.net" to="sess-man@myDomain.net" id="36d611a1-0231-46e7-b2bc-c06fe6840c57" type="set"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>CData size: 32</value></field><field type="list-single" var="domainjid"><value>CData size: 24</value></field><field type="list-single" var="max_items"><value>CData size: 4</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=set
[in_21-sess-man]   SessionManager.processCommand()    FINER:    OTHER command from: customComponent@myDomain.net
[in_21-sess-man]   SessionManager.getXMPPResourceConnection()  FINEST: Searching for resource connection for: sess-man@myDomain.net
[in_21-sess-man]   SessionManager.getResourceConnection()  FINEST: Session not null, searching session for jid: sess-man@myDomain.net
[in_21-sess-man]   SessionManager.getResourceConnection()  FINEST: Found session: XMPPResourceConnection=[user_jid=sess-man@myDomain.net, packets=6, connectioId=null, domain=myDomain.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=565578461, parentSession liveTime=31574], for jid: sess-man@myDomain.net
[in_21-sess-man]   SessionManager.processPacket()     FINEST:   processing packet: from=null, to=sess-man@myDomain.net, DATA=<iq from="customComponent@myDomain.net" to="sess-man@myDomain.net" id="36d611a1-0231-46e7-b2bc-c06fe6840c57" type="set"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>CData size: 32</value></field><field type="list-single" var="domainjid"><value>CData size: 24</value></field><field type="list-single" var="max_items"><value>CData size: 4</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=set, connection: XMPPResourceConnection=[user_jid=sess-man@myDomain.net, packets=6, connectioId=null, domain=myDomain.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=565578461, parentSession liveTime=31574]
[in_21-sess-man]   SessionManager.walk()              FINEST:   XMPPProcessorIfc: JabberIqStats (http://jabber.org/protocol/stats)Request: from=null, to=sess-man@myDomain.net, DATA=<iq from="customComponent@myDomain.net" to="sess-man@myDomain.net" id="36d611a1-0231-46e7-b2bc-c06fe6840c57" type="set"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>jabber.dev.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, conn: XMPPResourceConnection=[user_jid=sess-man@myDomain.net, packets=7, connectioId=null, domain=myDomain.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=565578461, parentSession liveTime=31574]
[in_21-sess-man]   SessionManager.walk()              FINEST:   XMPPProcessorIfc: JabberIqCommand (http://jabber.org/protocol/commands)Request: from=null, to=sess-man@myDomain.net, DATA=<iq from="customComponent@myDomain.net" to="sess-man@myDomain.net" id="36d611a1-0231-46e7-b2bc-c06fe6840c57" type="set"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>jabber.dev.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, conn: XMPPResourceConnection=[user_jid=sess-man@myDomain.net, packets=7, connectioId=null, domain=myDomain.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=565578461, parentSession liveTime=31574]
[in_21-sess-man]   SessionManager.processPacket()     INFO:     Impossible happened, please report to developer packet: from=null, to=sess-man@myDomain.net, DATA=<iq from="customComponent@myDomain.net" to="sess-man@myDomain.net" id="36d611a1-0231-46e7-b2bc-c06fe6840c57" type="set"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>jabber.dev.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, connection: XMPPResourceConnection=[user_jid=sess-man@myDomain.net, packets=7, connectioId=null, domain=myDomain.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=565578461, parentSession liveTime=31574].
[in_21-sess-man]   SessionManager.processPacket()     FINEST:   Packet processed by: [http://jabber.org/protocol/stats, http://jabber.org/protocol/commands]

Could you please explain where is a problem?


Replies (3)

Added by Wojciech Kapcia TigaseTeam over 1 year ago

There are two addressing for components:

  • in the XMPP realm - using componentName and the VHost (for example @component@tigase.org@)

  • in the internal Tigase addressing, where we use machine hostname resulting in component address being componentName@hostname (for example @componentName@node1.tigase.org@).

It looks like you are using VHost name in the list of administrators instead of hostname. This may get complicated in clustered environment therefore you can use {clusterNode} variable in the administrator lists: componentName@{clusterNode}

Added by Taras Panchak over 1 year ago

I tried it on my local Tigase instanse.

Also I changed in init.properties :

sess-man/admins[s]=admin@$HOST_NAME, bot1@$HOST_NAME, customComponent@$HOST_NAME

and modified :

<iq type="set" from="myComponent@myHostname.myCompany.net" to="sess-man@myHostname.myCompany.net" id="aaewwwbhj1a">
    <command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#get-online-users-list">
        <x xmlns="jabber:x:data" type="submit">
            <field type="hidden" var="FORM_TYPE">
                <value>http://jabber.org/protocol/admin</value>
            </field>
            <field type="list-single" var="domainjid">
                <value>myHostname.myCompany.net</value>
            </field>
            <field type="list-single" var="max_items">
                <value>None</value>
            </field>
        </x>
    </command>
</iq>

And received nearly the same result:

SessionManager.processPacket()     FINEST:   Received packet: from=null, to=null, DATA=<iq to="sess-man@myHostname.myCompany.net" type="set" id="8fe498a8-95ee-40f0-9e65-870f7572e936" from="customComponent@myHostname.myCompany.net"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field type="hidden" var="FORM_TYPE"><value>CData size: 32</value></field><field type="list-single" var="domainjid"><value>CData size: 24</value></field><field type="list-single" var="max_items"><value>CData size: 4</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=set
SessionManager.processCommand()    FINER:    OTHER command from: customComponent@myHostname.myCompany.net
SessionManager.getXMPPResourceConnection()  FINEST: Searching for resource connection for: sess-man@myHostname.myCompany.net
SessionManager.getResourceConnection()  FINEST: Session not null, searching session for jid: sess-man@myHostname.myCompany.net
SessionManager.getResourceConnection()  FINEST: Found session: XMPPResourceConnection=[user_jid=sess-man@myHostname.myCompany.net, packets=1002, connectioId=null, domain=myHostname.myCompany.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=762527508, parentSession liveTime=5011880], for jid: sess-man@myHostname.myCompany.net
SessionManager.processPacket()     FINEST:   processing packet: from=null, to=sess-man@myHostname.myCompany.net, DATA=<iq to="sess-man@myHostname.myCompany.net" type="set" id="8fe498a8-95ee-40f0-9e65-870f7572e936" from="customComponent@myHostname.myCompany.net"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field type="hidden" var="FORM_TYPE"><value>CData size: 32</value></field><field type="list-single" var="domainjid"><value>CData size: 24</value></field><field type="list-single" var="max_items"><value>CData size: 4</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=set, connection: XMPPResourceConnection=[user_jid=sess-man@myHostname.myCompany.net, packets=1002, connectioId=null, domain=myHostname.myCompany.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=762527508, parentSession liveTime=5011881]
SessionManager.walk()              FINEST:   XMPPProcessorIfc: JabberIqStats (http://jabber.org/protocol/stats)Request: from=null, to=sess-man@myHostname.myCompany.net, DATA=<iq to="sess-man@myHostname.myCompany.net" type="set" id="8fe498a8-95ee-40f0-9e65-870f7572e936" from="customComponent@myHostname.myCompany.net"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>myHostname.myCompany.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, conn: XMPPResourceConnection=[user_jid=sess-man@myHostname.myCompany.net, packets=1003, connectioId=null, domain=myHostname.myCompany.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=762527508, parentSession liveTime=5011881]
SessionManager.walk()              FINEST:   XMPPProcessorIfc: JabberIqCommand (http://jabber.org/protocol/commands)Request: from=null, to=sess-man@myHostname.myCompany.net, DATA=<iq to="sess-man@myHostname.myCompany.net" type="set" id="8fe498a8-95ee-40f0-9e65-870f7572e936" from="customComponent@myHostname.myCompany.net"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>myHostname.myCompany.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, conn: XMPPResourceConnection=[user_jid=sess-man@myHostname.myCompany.net, packets=1003, connectioId=null, domain=myHostname.myCompany.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=762527508, parentSession liveTime=5011881]
SessionManager.processPacket()     INFO:     Impossible happened, please report to developer packet: from=null, to=sess-man@myHostname.myCompany.net, DATA=<iq to="sess-man@myHostname.myCompany.net" type="set" id="8fe498a8-95ee-40f0-9e65-870f7572e936" from="customComponent@myHostname.myCompany.net"><command node="http://jabber.org/protocol/admin#get-online-users-list" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field type="list-single" var="domainjid"><value>myHostname.myCompany.net</value></field><field type="list-single" var="max_items"><value>None</value></field></x></command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set, connection: XMPPResourceConnection=[user_jid=sess-man@myHostname.myCompany.net, packets=1003, connectioId=null, domain=myHostname.myCompany.net, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false, parentSession hash=762527508, parentSession liveTime=5011881].

Added by Wojciech Kapcia TigaseTeam over 1 year ago

After taking a look at the issue it looks that most likely this is a result of permissions - your packet has:

…</command></iq>, SIZE=562, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=set

Please note @PERMISSION=NONE@.

Take a look at possible values in tigase.server.Permissions and adjust them accordingly (having NONE prevents further processing of the command)

    (1-3/3)