سؤال

I am recently working on Openfire client. I've got this strange issue that I couldn't figure out so far (i've got some clues, but still no solid solution). We've got 2 openfire servers:

  • first that we were using for testing it was hosted on normal pc conected to the internet through adsl, server was behind NAT, everything configured smoothly, working perfect. Our client was connecting without any issues.
  • second (let's call it production) professional dedicated server located somewhere in germany with OF instaled, same OS as on the testing one, OF set up in exactly the same way

Now when connecting to production from our client we experianced following issue when trying to authenticate:

javax.net.ssl.SSLException: Received fatal alert: internal_error at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:806) at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:267) at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43) at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70) java.lang.IllegalStateException: Not connected to server. at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:445) at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:69) at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:352) at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203) at Main.connectToJabber(Main.java:31) at Main.main(Main.java:16) Exception in thread "main" java.lang.IllegalStateException: Not connected to server. at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:445) at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:69) at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:362) at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203) at Main.connectToJabber(Main.java:31) at Main.main(Main.java:16)

Now the funniest part: when I connect to the production server using our client from my flat i don't see that error, when we are connecting to the production from other developer flat we've got this error, we've got different internet providers (i don't know if that may have something to do with that). We've spent all night looking at it and so far no clue. We wrote basic code just to check the connection:

public static void connect() {
    ConnectionConfiguration cc = new ConnectionConfiguration("prod ip",
            5222);
    cc.setCompressionEnabled(true);
    cc.setSASLAuthenticationEnabled(true);
    Connection connection = new XMPPConnection(cc);
    try {
        connection.connect();
        connection.login(login, pass, "resource");
        System.out.println(connection.isSecureConnection() +  " " + connection.isUsingCompression());

    } catch (XMPPException e1) {
        e1.getStackTrace();
    }
}

Some observations:

  • When line connection.login(...) commented, there is no error, so whatever is causing the error is there
  • When connecting the testing server System.out... writes true false,
  • When connecting the production server System.out... writes false false
  • Tried with all combinations of: cc.setCompressionEnabled() cc.setSASLAuthenticationEnabled(); (true, true, false true, true false, false false)
  • despite the error, user is logged in To sum up:

Connection with testing environment works always, with production: from my location - no problem, other location - mentioned error, we use SMACK API 3.2.1

One of the ideas was that it has to do something with the certificates.

Any hints or ideas highly appriciated

هل كانت مفيدة؟

المحلول

Maybe a sleep(x) between the connect() and the login() call could fix this. A few seconds for the sleep() should be enough. Source

نصائح أخرى

Bad bad solution! because u don't know connection speed and also u stop your app from continuing to login if connection established at early moments. A solution that I can offer for now is to addConnectionListener and call login() in 'reconnectionSuccessful()' function, and I hope this function will call for the first time not just after connection dropped and connected again! if not, It shows the bad architecture of smack library.

I also use a sleep after connect() also... it's not ideal sure, but it's a reliable workaround.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top