I am having problems with the delivery of Message packets.
I am developing a custom IM client using the Jabber-net Library against the eJabberd server.
I also use the Spark Client for testing and for trouble shooting issues.
Here is the situation:
Suppose the following two clients are logged on:
1) IM custom (logged in as source@server\custom)
2) IM Spark (logged in as destination@server\spark)
When I send the message:
<message id="JN_23" from="source@server\custom" to="destination@server\spark"><x jid="room1@server" xmlns="jabber:x:conference" /></message>
The response I get is:
<message from='destination@server\spark' to='source@server/custom' type='error' id='JN_23'><x jid='room1@server' xmlns='jabber:x:conference'/><error code='404' type='cancel'><remote-server-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></message>
Using the same two clients when I send the message:
<message id="JN_23" from="source@server\custom" to="destination@server"><x jid="room1@server" xmlns="jabber:x:conference" /></message>
the message is delivered just fine
The above and other investigation have led me to discover that:
1) messages are delivered to the Spark client only if the to attribute excludes the Resource
2) messages are delivered to my custom client that uses the Jabber-net libary ONLY if the to attribute includes the Resource
I would very much appreciate suggestions as to what could be the cause of this difference in behavior.
Thanks,
Casey
clarification
Suppose the following two clients are logged on:
1) IM custom (logged in as chanks@v-doc-imchat.infoassure.local\N2K)
2) IM custom (logged in as btroxell@v-doc-imchat.infoassure.local\N2K)
The following message is not being delivered by the server:
<message id="JN_26" from="chanks@v-doc-imchat.infoassure.local" to="btroxell@v-doc-imchat.infoassure.local"><x jid="room1@conference.v-doc-imchat.infoassure.local" xmlns="jabber:x:conference" /></message>
The following message is also not being delivered:
<message id="JN_27" to="btroxell@v-doc-imchat.infoassure.local" type="chat" from="chanks@v-doc-imchat.infoassure.local/N2K"><thread>5a72cf4a-cd21-46fa-bc0f-b0ea927bae73</thread><body>ping</body></message>
The following message IS being delivered:
<message id="JN_17" to="chanks@v-doc-imchat.infoassure.local/N2K" type="chat" from="btroxell@v-doc-imchat.infoassure.local/N2K"><thread>4b758a5d-b2ee-492a-9480-0e8d53aea307</thread><body>ping</body></message>
The following message result in an error:
<message id="JN_24" from="btroxell@v-doc-imchat.infoassure.local" to="chanks@v-doc-imchat.infoassure.local\n2k"><x jid="room1@conference.v-doc-imchat.infoassure.local" xmlns="jabber:x:conference" /></message>
Message that comes back with error:
<message from='chanks@v-doc-imchat.infoassure.local\n2k' to='btroxell@v-doc-imchat.infoassure.local/N2K' type='error' id='JN_24'><x jid='room1@conference.v-doc-imchat.infoassure.local' xmlns='jabber:x:conference'/><error code='404' type='cancel'><remote-server-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></message>
Thus for my client
Message packets without an x element are only delivered if the 'to' incluces the Resource
Message packets with an x element generate an error if the 'to' includes the Resource
Message packets with an x element seem to do nothing if the 'to' is a Bare JID
Thanks,
Casey
All works correctly for me!
I use ejabberd trunk SVN, and two Tkabber 0.12.0 clients. All works correctly here.
The following message is not being delivered by the server:
<message id="JN_26" from="chanks@v-doc-imchat.infoassure.local" to="btroxell@v-doc-imchat.infoassure.local"><x jid="room1@conference.v-doc-imchat.infoassure.local" xmlns="jabber:x:conference" /></message>
chanks sends:
<message id="JN_26" from="chanks@v-doc-imchat.infoassure.local"
to="btroxell@v-doc-imchat.infoassure.local">
<x jid="room1@conference.v-doc-imchat.infoassure.local" xmlns="jabber:x:conference" />
</message>
btroxell receives:
<message from='chanks@v-doc-imchat.infoassure.local/N2K'
id='JN_26'
xml:lang='es'
to='btroxell@v-doc-imchat.infoassure.local'>
<x xmlns='jabber:x:conference'
jid='room1@conference.v-doc-imchat.infoassure.local'/>
</message>
The following message is also not being delivered:
<message id="JN_27" to="btroxell@v-doc-imchat.infoassure.local" type="chat" from="chanks@v-doc-imchat.infoassure.local/N2K"><thread>5a72cf4a-cd21-46fa-bc0f-b0ea927bae73</thread><body>ping</body></message>
chanks sends:
<message id="JN_27" to="btroxell@v-doc-imchat.infoassure.local" type="chat"
from="chanks@v-doc-imchat.infoassure.local/N2K">
<thread>5a72cf4a-cd21-46fa-bc0f-b0ea927bae73</thread><body>ping</body></message>
btroxell receives:
<message from='chanks@v-doc-imchat.infoassure.local/N2K'
id='JN_27'
xml:lang='es'
type='chat'
to='btroxell@v-doc-imchat.infoassure.local'>
<thread>5a72cf4a-cd21-46fa-bc0f-b0ea927bae73</thread>
<body>ping</body>
</message>
The following message IS being delivered:
<message id="JN_17" to="chanks@v-doc-imchat.infoassure.local/N2K" type="chat" from="btroxell@v-doc-imchat.infoassure.local/N2K"><thread>4b758a5d-b2ee-492a-9480-0e8d53aea307</thread><body>ping</body></message>
chanks sends:
<message id="JN_17" to="chanks@v-doc-imchat.infoassure.local/N2K" type="chat"
from="btroxell@v-doc-imchat.infoassure.local/N2K">
<thread>4b758a5d-b2ee-492a-9480-0e8d53aea307</thread><body>ping</body></message>
chanks receives:
<message from='chanks@v-doc-imchat.infoassure.local/N2K'
id='JN_17'
xml:lang='es'
type='chat'
to='chanks@v-doc-imchat.infoassure.local/N2K'>
<thread>4b758a5d-b2ee-492a-9480-0e8d53aea307</thread>
<body>ping</body>
</message>
The following message result in an error:
<message id="JN_24" from="btroxell@v-doc-imchat.infoassure.local" to="chanks@v-doc-imchat.infoassure.local\n2k"><x jid="room1@conference.v-doc-imchat.infoassure.local" xmlns="jabber:x:conference" /></message>
That stanza has the To JID wrongly formed, as I explained before.
clarification
Thanks for the comment.
The original samples I posted did have the "/" the wrong way.
This mistake does not occur in my code and occured only becuase I mistyped the sample during my post.
If you look at the clarrify samples (where I copied and pasted the XML directly) you will notice that the JID is formatted correctly.
so I am still at a loss as to the source of the problem.
Casey
user@server/resource
You made here a very simple mistake :)
<message id="JN_23" from="source@server\custom" to="destination@server\spark"><x jid="room1@server" xmlns="jabber:x:conference" /></message>
In that XMPP stanza, the destination JID is user "destination" and server "server\spark". The separator for resource is /, not \. So you didn't build your destination JID correctly.
The sender JID is of course also wrong: "source@server\custom". However, ejabberd did not complain to you because ejabberd just throws the attribute "FROM" to the trash to avoid malicious users to fake their identity. I found this behaviour inXMPP-IM-bis: 9.1.2.1. Client-to-Server Streams :
2. When the server receives an XML stanza from a client and the stanza includes a 'from' attribute, the server MUST either (a) [...] or (b) override the provided 'from' attribute by adding a 'from' attribute as specified under Rule #1.