Possible Jive Messenger bug with XML message body

I have two Java programs - a server and a client, communicating using XMPP. The server program fetches data from a database and packages that data into an XML structure.

The server program prepares an XMPP message with the XML structure as message body. XMPP message is then sent to the client program.

Both the server and client programs use Smack library to send/receive XMPP messages.

When JabberD 1.4.x is used as the XMPP server, XML message body is correctly passed from the server program to the client program.

However, when Jive Messenger is used for XMPPP server, the last character in the XML structure (">") is removed.

Client program receives the message without the last “>”.

Example:

Server program constructs the following XML

*

<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’ ApplicantName = ‘‘User1’’/>

When Jive Messenger is used as XMPP sever, the client program receives following XML

*

<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’ ApplicantName = ‘‘User1’’/>

</Data*

With JabberD 1.4.2 as XMPP server, the client program is receiving complete XML.

Just to be clear – are both “server” and “client” connecting as clients to the XMPP server? Also, what version of Messenger are you testing with?

Regards,

Matt

hi Matt,

Yes. client and server apps are connecting to the same XMPP server. I am using the latest version of Messenger - version 2.0.0 Beta.

Just now I have re-checked this issue using Exodus and confirm the issue. With Jive Messenger, the last XML char is removed.

Kiran

Hey Kiran,

I’‘d like to reproduce to problem so I can fix it. Could you post the complete packet that when a client sends to the server the other client doesn’'t receive it completely?

Any hint you can give me to reproduce the problem will be greatly appreciated.

Thanks,

– Gato

hi Gato,

Here is an easy way to re-create this issue:

  • Start Jive Messenger 2.0.0. Beta 1

  • From two separate systems running Exodus or some other Jabber client, login to the same IP running Jive Messenger

(I have checked this issue with Exodus and also with Java code using Smack too).

  • From one system to another, send this message:

*<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’ ApplicantName = ‘‘User1’’/>

  • The second system will get one character less:

<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’ ApplicantName = ‘‘User1’’/></Data

This problem does not arise with JabberD.

Regards,

Kiran

Kiran,

Could you send me the complete packet which includes your DATA element?

I tried sending something like this:

<message to="jatul@localhost/Work">
<body>asd</body>
<Data>
<ID value=''1'' ApplicationID=''AA1'' ApplicantName = ''User1''/>
</Data>
</message>

and the other client received the complete message as you can see here:

<message from="jatul@localhost/Exodus" to="jatul@localhost/Work">
<body>asd</body>
<Data>
<ID value="1" ApplicationID="AA1" ApplicantName="User1"></ID>
</Data>
</message>

Regards,

– Gato

<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’

ApplicantName = ‘‘User1’’/>

This is not a valid XMPP packet. Valid XMPP packets are message, presence, or IQ. If you include a packet extension, it must be in it’'s own namespace. So, you could have the following:

<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’

ApplicantName = ‘‘User1’’/>

I tried the above and it worked perfectly in my test environment. Can you include the full packet you’'re trying to send back and forth?

Regards,

Matt

Doh! Gato beat me to a reply.

-Matt

My “server” application code is somewhat like this:

String sXMLData = “<ID value = ‘‘1’’ ApplicationID = ‘‘AA1’’ ApplicantName = ‘‘User1’’/>”;

try

{

XMPPConnection xmppConnection = new XMPPConnection(“sys1”);

xmppConnection.login(

“user1”,

“password”);

Message message = new Message(“user2@sys1”);

message.setSubject(“Data”);

message.setBody(sXMLData);

xmppConnection.sendPacket(message);

}

catch(XMPPException xmppException)

{

xmppException.printStackTrace();

}

With the above code snippet, last char (">") in the message is removed when received either by Exodus or a Java program (that uses Smack).

I noticed this problem when my application (which was earlier hosted with JabberD) failed to work correctly when tested with Jive Messenger.

Kiran,

Thanks, this gives us something to test. However, the way you’‘re sending XML isn’‘t the “proper” way according to XMPP. What you should do instead is add a packet extension – this will add XML to the message’‘s own XML instead of escaping the XML as part of the message body. We’'ll let you know what we find from testing.

Regards,

Matt

Thanks for the suggestion.

I guess it means writing a new class either extending DefaultPacketExtension or implementing PacketExtension.

Or as suggested in the JavaDoc for DefaultPacketExtension, develop a custom PacketExtensionProvider (as I have multiple attributes).

Am I right?

Regards,

Kiran

Kiran,

You can follow this link to learn how to add new Smack extension: http://www.jivesoftware.org/builds/smack/docs/latest/documentation/providers.htm l. Or you can also take a look at current implemented extensions to see them “in action”.

The idea is for you to implement the PacketExtension interface and create a new PacketExtensionProvider which must also be registered.

Let us know if you need further help.

Regards,

– Gato