Force "From" attribute in outgoing stanzas


It seems like Smack removes ‘from’ attribute from all outgoing stanzas as per this issue .

Generally this behavior works fine, but I’m trying to implement a proposed extension ( ) . Apparently ejabberd expects ‘from’ attribute in custom-iq stanza to function properly. Is there a way to force “from” attribute into a particular packet.

Here is my code:

public class MucSubIq extends IQ {...}
final MucSubIq mucSubIq = new MucSubIq(this.nick);
Log.i(TAG,mucSubIq.toXML().toString());  //Prints: <iq to='' from='' id='M630P-12' type='set'>...</iq>
connection.sendStanza(mucSubIq); //Debug Output: SENT (0): <iq to='' id='M630P-12' type='set'>...</iq>

XMPP servers are required to stamp the from attribute of incoming stanzas received on c2s links. If it’s true what you are saying, then it’s an ejabberd bug and you should report it to the ejabberd developers.

Never the less you can use AbstractXMPPConnection (Smack 4.1.7 API) 's setFromMode() to change the Smack behavior.