Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
claytoneu #1
Member since Sep 2011 · 5 posts
Group memberships: Members, Premium
Show profile · Link to this post
Subject: Feedback Loop (kind of) Situation with XMPP Components
I've run into an odd situation with components. I'm not sure if what I'm doing is valid, but I haven't found anything in the XEP-0114 that says what I'm doing is against the protocol. =)

I'm using ejabberd as my XMPP server and I've written a component using Matrix. Let's say my host address is "example.com". Instead of attaching my component to a subdomain such as "component.example.com", I've found that ejabberd will allow me to attach it to "example.com" without any complaints.

One of the reasons (and there are many more) why I've done this is so that I can set up a transparent routing system where I can intercept messages sent to a JID representing a group such as "techsupport@example.com" and route traffic to a JID for an actual user like "johnsmith@example.com". When responses come back from "johnsmith@example.com", the recipient on the other end will not see "johnsmith@example.com" but "techsupport@example.com".

Now with this setup, I've gotten into a situation where the component listening on "example.com" will intercept incoming messages just fine. However, after the component has intercepted the message, it needs to send the same message out to the intended recipient. When the component sends the message, it will intercept the same message it just sent out.

This is the code that I'm using to catch and resend message packets which is attached to the component's OnMessage event:

void Component_OnMessage(object sender, MessageEventArgs e)
{
    // Do some logging...
           
    // Resend message
    Send( e.Message);
}

Here is a sample log of incoming and outgoing traffic from the component after "user@example.com" has sent a message to "techsupport@example.com". This is just from a small test program I wrote and doesn't actually do any routing as mentioned above. Interestingly, it doesn't loop infinitely - it only loops once.

Please let me know if there is any way around this or if what I'm doing is completely out of the intentions of how components are to be used. One of the reasons I went down this route is that I'd rather use Matrix than learn how to code in erlang. =)

RECEIVE:
<message from="user@example.com/2141905385131671892041003" to="techsupport@example.com" type="chat" xmlns="jabber:component:accept">
  <body>TEST MESSAGE</body>
  <active xmlns="http://jabber.org/protocol/chatstates" />
</message>

SEND:
<message from="user@example.com/2141905385131671892041003" to="techsupport@example.com" type="chat" xmlns="jabber:component:accept">
  <body>TEST MESSAGE</body>
  <active xmlns="http://jabber.org/protocol/chatstates" />
</message>

RECEIVE:
<message from="user@example.com/2141905385131671892041003" to="techsupport@example.com" type="chat" xmlns="jabber:component:accept">
  <body>TEST MESSAGE</body>
  <active xmlns="http://jabber.org/protocol/chatstates" />
</message>

SEND:
<message from="user@example.com/2141905385131671892041003" to="techsupport@example.com" type="chat" xmlns="jabber:component:accept">
  <body>TEST MESSAGE</body>
  <active xmlns="http://jabber.org/protocol/chatstates" />
</message>
This post was edited on 2011-09-22, 23:12 by claytoneu.
Avatar
Alex #2
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Components must be always on a subdomain. The server routes stanzas based on the domain. When stanzas are addressed to the XMPP domain the server is configured to then the server processes these stanzas, when they are addressed to a subdomain which is configured for a component then it forwards these messges to the component.

Another solution is writing a bit whichis often easier. You can write a bot which connects as client johnsmith@example.com to your server and stays online 24/7

You could also add a jid of the format johnsmith@comp1.example.com to your roster, but bot are normally easier to write in this case.

Alex
Avatar
claytoneu #3
Member since Sep 2011 · 5 posts
Group memberships: Members, Premium
Show profile · Link to this post
Ah, thanks Alex!
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS