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:
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. =)
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);
}
{
// 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>
<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>