The Gajim client on windows and smack debbuger return this kind of stanza, same as the one in the xmpp specs.
Hail to theeyet on smack in onStanza
it returns this one:
How do you fix this? Here’s some parts of the code.
public class XmppServiceSmackImpl implements XmppService, StanzaListener, ConnectionListener {
XmppServiceListener xmppServiceListener;
Logger logger = Logger.getLogger(XmppServiceSmackImpl.class.getName());
XMPPTCPConnection connection;
String password;
public XmppServiceSmackImpl(XmppServiceListener xmppServiceListener) {
this.xmppServiceListener = xmppServiceListener;
}
@Override
public void setup(String jid, String password, String authMethod, String hostname, Integer port) {
final String[] jidParts = jid.split("@");
String[] serviceNameParts = jidParts[1].split("/");
String serviceName = serviceNameParts[0];
XMPPTCPConnectionConfiguration.Builder confBuilder = XMPPTCPConnectionConfiguration.builder()
.setServiceName(serviceName)
.setUsernameAndPassword(jidParts[0], password)
.setConnectTimeout(3000)
//.setDebuggerEnabled(true)
.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
if (serviceNameParts.length>1){
confBuilder.setResource(serviceNameParts[1]);
} else {
confBuilder.setResource(Long.toHexString(Double.doubleToLongBits(Math.random()) ));
}
if (hostname != null){
confBuilder.setHost(hostname);
}
if (port != null){
confBuilder.setPort(port);
}
if (trustedHosts.contains(hostname) || (hostname == null && trustedHosts.contains(serviceName))){
confBuilder.setCustomSSLContext(UnsafeSSLContext.INSTANCE.getContext());
}
XMPPTCPConnectionConfiguration connectionConfiguration = confBuilder.build();
XMPPTCPConnection.setUseStreamManagementDefault(true);
XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
connection = new XMPPTCPConnection(connectionConfiguration);
// Disable automatic roster request
Roster roster = Roster.getInstanceFor(connection);
roster.setRosterLoadedAtLogin(false);
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
connection.addAsyncStanzaListener(this, null);
connection.addConnectionListener(this);
connection.addStanzaAcknowledgedListener(this);
}
@Override
public void processPacket(Stanza packet) throws SmackException.NotConnectedException {
logger.log(Level.WARNING, "Received stanza: " + packet);
this.xmppServiceListener.onStanza(packet);
}
}