Unable to get message data

Currently on version 4.3.1

When logging out stanza I can see that I get messages from the debugger coming in in this format

<message xmlns="jabber:client" msgid="9dda9491-175d-48e0-91dd-e77f0c812995" type="chat" from="senderjid" to="receiverjid">
	<body>Hi</body>
	<thread>9132088a14de4850b7d78e260f8c30e2</thread>
	<active xmlns="http://jabber.org/protocol/chatstates"></active>
	<timestamp>1565988380622</timestamp>
</message>

By the time I can handle this message it seems to strip the msgid value id away. I know that it isn’t good practice to have it there but the server we are connecting to has it set up that way and there’s nothing I can do about it.

I’ve used the different providers but there doesn’t seem to be one that can handle this situation. Is there any way for me to be able to parse out this value?

You probably have to fork Smack and modify the Message parsing logic to deserialize and take the msgid value in consideration.

Since the msgid is not compliant to the XMPP specification Smack will not parse it for you. However I’d strongly advise you to stay protocol compliant and use either normal message ids, Stable and Unique Stanza IDs (also supported by Smack :wink: ) or implement your own extension element, eg.

<message xmlns="jabber:client" type="chat" from="senderjid" to="receiverjid">
	<body>Hi</body>
	<thread>9132088a14de4850b7d78e260f8c30e2</thread>
	<active xmlns="http://jabber.org/protocol/chatstates"></active>
	<timestamp>1565988380622</timestamp>
        <msgid xmlns="urn:xmpp:my_ns" id="9dda9491-175d-48e0-91dd-e77f0c812995" />
</message>

There is an orphaned PR which would add support for this:

Although I really recommend putting custom data in custom extension elements, and not in stanza attributes.

What Paul said! :slight_smile:

Although there is a little nit:

That is debatable. I think custom stanza attributes are actually compliant, but would hope that it would be not the case.

Thanks for the response guys…

Although I really recommend putting custom data in custom extension elements, and not in stanza attributes.

I wish I could add it to an extension but can’t. I don’t have control over the stanzas I get back and this is just one of the hoops I’m having to jump through. It would save me from having to make many unnecessary API calls if that PR would get merged in :slightly_smiling_face: .

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.