Hi everyone,
As part of a larger project, I have to create and log in to an XMPP Connection so as to subscribe to occasional events published by the server.
I have no choice but to use Smack v3.2.1 – my client insists on that version.
The client also insists that we use port 5223, not 5222, but doesn’t have any knowledge of how Smack works or any restrictions it may have in this respect. I have watched remotely as they ensured that both ports 5222 and 5223 were added to the Windows firewall, and the Windows telnet command line seems to open a connection to both ports, just as a simple test.
With all this in mind, I started out by seeing how far I could get with port 5222 – and it worked fine. ConnectionConfiguration was good, and the connection handle was passed onto XMPPConnection, which was able to log in and join the relevant chat room. Some seconds later I started receiving the relevant published events from the server. All good.
However, it was at this point that the client asked to switch to port 5223, and has installed a security certificate for it. The login attempt now results in this stack trace (the first two lines are output by my own Java):
Temp/Hum XMPPConnection connected ...
Temp/Hum XMPPConnection Login:
org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not \u15 (position: START_DOCUMENT seen \u15... @1:1)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1519)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
Apologies at this point: I realise there was another post on this forum way back over 10 years ago with a similar problem, but it hasn’t helped me. It seemed to suggest that port 5223 could not be used – is this true ? In the hope that it might make a difference, I specified SecurityMode.enabled but it didn’t help. My code is currently this (it’s the con.login that’s failing when port 5223 is specified, but works for port 5222):
BXmppConfig xmppConfig = host.getXmppConfig();
ConnectionConfiguration config = new ConnectionConfiguration(
host.getAddress(),
xmppConfig.getPort(),
xmppConfig.getTempHumidityRoomDomain()
);
config.setSecurityMode(SecurityMode.enabled);
config.setDebuggerEnabled(true);
XMPPConnection con = new XMPPConnection(config);
try {
con.connect();
System.out.println("Temp/Hum XMPPConnection connected ...");
} catch (XMPPException e) {
System.out.println("Temp/Hum XMPPConnection connect failed! Please check server configuration");
e.printStackTrace();
}
try {
System.out.println("Temp/Hum XMPPConnection Login:");
con.login(
xmppConfig.getTempHumidityUser(),
xmppConfig.getTempHumidityPassword(),
xmppConfig.getTempHumidityAlias()
);
System.out.println("Temp/Hum XMPPConnection login successful");
startChat(con, xmppConfig);
} catch (XMPPException e) {
System.out.println("Temp/Hum XMPPConnection login failed! Please check user credentials");
e.printStackTrace();
}
Are there any other hints or tips that anyone can suggest I try, or information I could ask the client to provide me that may add more context to this post ? Can I configure Smack to log some more detailed output to the console regarding what it is doing under the covers ?
Thanks in advance