Unable to connect to my openfire server

Hello everybody,

yesterday I entered in the fabulous world of XMPP… That’s not a piece of cake. Anyway… I installed openfire on a server and that went well. To test it, I installed Spark on another computer and I tried to connect to my OpenFire server and… it went well, so cool… I told myself that I was ready to build an android app (which is my final goal) that connect to this OpenFire server and that went well… No, I’m kidding, that’s when the pain started…

I downloaded the very last version of asmack (I guess it’s the very last as its date is 16 of augustus). At the end, I came up with the following code:

private class OpenConnectionAction extends AsyncTask<Void, Void, Void>

{

@Override

protected Void doInBackground(Void… arg0)

{

SmackAndroid.init(getApplicationContext());

ConnectionConfiguration config = new ConnectionConfiguration(“THE IP OF THE SERVER”);

connection = new XMPPTCPConnection(config);

try

{

Log.d(“WISH”, “Connecting…”);

connection.connect();

Log.d(“WISH”, “Logging in…”);

connection.login(“Admin”, “********”);

Log.d(“WISH”, “Connected!”);

}

catch (Exception ex)

{

connection = null;

Log.d(“WISH”, "UNABLE TO CONNECT: " + Log.getStackTraceString(ex));

}

return null;

}

}

When I execute this code, I see the “Connecting…” message and after 5 or 6 seconds, I enter the catch. First, I tried to display the message of the exception but it was null. When I display the stack trace of it, I get this:

08-17 02:53:53.532: D/WISH(23942): UNABLE TO CONNECT: org.jivesoftware.smack.SmackException$NoResponseException

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.XMPPConnection.throwConnectionExceptionOrNoResponse(XMPP Connection.java:548)

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwConnectionExceptionOrNoRespon se(XMPPTCPConnection.java:864)

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.j ava:479)

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:437)

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:808)

08-17 02:53:53.532: D/WISH(23942): at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:396)

08-17 02:53:53.532: D/WISH(23942): at com.areaprog.wish.activities.ProfileActivity$OpenConnectionAction.doInBackgroun d(ProfileActivity.java:64)

08-17 02:53:53.532: D/WISH(23942): at com.areaprog.wish.activities.ProfileActivity$OpenConnectionAction.doInBackgroun d(ProfileActivity.java:1)

Yeah well… No response, awesome… I tried to put “5222” as second parameter of the ConnectionConfiguration object but it does not change anything. The weird thing is I tried to replace the IP by “google talk stuff” and then I got a different error message (saying something with plain authentication) but at least I got a message, showing that the server could be reached… So the question is “why can’t I connect my server while Spark can with the same information…”

Thanks for your help.

Hello again. I don’t know if it can help but I activate debug logs and when I try to connect (still though my application), the following lines are logged:

javax.net.ssl.SSLException: Inbound closed before receiving peer’s close_notify: possible truncation attack?

at sun.security.ssl.Alerts.getSSLException(Unknown Source)

at sun.security.ssl.SSLEngineImpl.fatal(Unknown Source)

at sun.security.ssl.SSLEngineImpl.fatal(Unknown Source)

at sun.security.ssl.SSLEngineImpl.closeInbound(Unknown Source)

at org.apache.mina.filter.support.SSLHandler.destroy(SSLHandler.java:167)

at org.apache.mina.filter.SSLFilter.sessionClosed(SSLFilter.java:367)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextSessionClosed(Abst ractIoFilterChain.java:269)

at org.apache.mina.common.support.AbstractIoFilterChain.access$800(AbstractIoFilte rChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.sessionClosed( AbstractIoFilterChain.java:633)

at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.sessionClosed(A bstractIoFilterChain.java:484)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextSessionClosed(Abst ractIoFilterChain.java:269)

at org.apache.mina.common.support.AbstractIoFilterChain.fireSessionClosed(Abstract IoFilterChain.java:264)

at org.apache.mina.common.support.IoServiceListenerSupport.fireSessionDestroyed(Io ServiceListenerSupport.java:224)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.doRemove(SocketIoProcess or.java:188)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$600(SocketIoProce ssor.java:45)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:489)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

2014.08.17 13:14:38 org.apache.mina.filter.executor.ExecutorFilter - Launching thread for /85.201.26.69:49661

2014.08.17 13:14:38 org.apache.mina.filter.executor.ExecutorFilter - Exiting since queue is empty for /85.201.26.69:49661

Okay… Sorry for the triple post but while waiting for an answer to this topic, I continued my investigation. I wondered why I had a SSL connection while I was trying to connect though normal HTTP. Then I foudn over the Internet that I could do something like that:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

To force the connection though HTTP instead of HTTPS… And it worked Well… At least, I’m connected… Now let’s see how I can developp what I want.

Thanks

To force the connection though HTTP instead of HTTPS
XMPP (core, ie. without using BOSH) does not use HTTP nor HTTPS. Just plain TCP.

I guess that using an unsecured connection is… not secure (good guess) but I don’t really want to spend a lot of time to configure the security on my server right now. I’d like first to developp my application to see if what I want to do is feasible or not and then implement the security.

So, is it easy, once every works in an unsecured way to switch to a secure one? In my mind, it would something like “you do stuff on your server to enable the security and you remove the line with setSecurityMode and that’s it”. Is it more like this or more like “you’ll have to change 95% of your code” ?

Thanks

and you remove the line with setSecurityMode and that’s it"
Yeah, you set securityMode to required and Smack will only connect if the connection is SSL/TLS secured. But you will need to have a understanding of SSL/TLS to provide a decent security in your application.

I guess so. I have time to learn that

Thanks for your help, I’ll be able to start my application slowly.

There is also #smack (freenode) if you have questions.