Smack: Connecting through SSL on Port 5223


Since a few days I’m searching for a solution. I want to connect to a server who offers SSL encryption on port 5223. I searched here in the forum and on google. I found some articles and posts which talked about a class named SSLXMPPConnection in Smack. But I can’t find it in Smack 3.0.4. Then I tried to give the ConnectionConfiguration the SSLSocketFactory, but this also results in a “Server not Responding”-Error when the key of the servers is in the truststore.

It would be very nice if I get some help and/or sample code on how to connect to SSL encrypted ports with Smack 3.0.4.

Thanks in advance

Hi, you need to use the setSocketFactory(). Spark uses this technique if you need another example. Copy the from spark into your project, and then import into your “”

Then, in your connection, use:

** xmppConfig = new ConnectionConfiguration(“”, 5223);
xmppConfig.setSocketFactory(new DummySSLSocketFactory());**

** userXmppConnection = new XMPPConnection(xmppConfig);

Hope this helps, worked ok in my app. You’ll need to turn on all the SSL options on your server, proper certs and keystores.

If this doesn’t work, you should try the Spark app, in the advanced options and force the connection to and port 5223, then select the “Use OLD SSL port method”. If you still get the error from Spark, you probably have port 5223 blocked, or not open. If you know this to be ok, then you probably have some keystore issue. Use the keytool -keystore yourkeystore -list to see if your keystore has your server entries as expected.

Ok, thanks for your answer. I already set **xmppConfig.setSocketFactory(SSLSocketFactory.getDefault()); **May I aksed what’s the difference between the SSLSocketFactory and the DummySSLSocketFactory()?

The Dummy sets up the SSLContext that handles the TrustManager for verifying the certificates. You can then customize the TrustManager if desired.