aSmack连接到openfire。无法连接,openfire错误日志显示“无法识别的SSL消息,明文连接?”

时间:2013-06-04 19:30:49

标签: android xmpp openfire smack asmack

您好我正在尝试连接到openfire服务器。使用以下代码:

        ConnectionConfiguration config = new ConnectionConfiguration(hostName, 5222);
        XMPPConnection connection = new XMPPConnection(config);

        try {
            connection.connect();
        } catch (XMPPException e) {
            if (e != null){
                Log.d(",myapp", Log.getStackTraceString(e));
            }
        }
        try {
            connection.login(userName, "password");
        } catch (XMPPException e) {
            if (e != null){
                Log.d("XMPPConnection", "Authentication Failure");
            }
        }

它在connection.connect()上失败;并且堆栈跟踪是:

06-04 15:23:51.961: D/,myapp(20261): Connection failed. No response from server.: 
06-04 15:23:51.961: D/,myapp(20261):    at org.jivesoftware.smack.PacketReader.startup(PacketReader.java:115)
06-04 15:23:51.961: D/,myapp(20261):    at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:655)
06-04 15:23:51.961: D/,myapp(20261):    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:615)
06-04 15:23:51.961: D/,myapp(20261):    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1034)
06-04 15:23:51.961: D/,myapp(20261):    at com.coffeeenterprise.resources.ConnectToXMPPTask.doInBackground(ConnectToXMPPTask.java:30)
06-04 15:23:51.961: D/,myapp(20261):    at com.coffeeenterprise.resources.ConnectToXMPPTask.doInBackground(ConnectToXMPPTask.java:1)
06-04 15:23:51.961: D/,myapp(20261):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-04 15:23:51.961: D/,myapp(20261):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-04 15:23:51.961: D/,myapp(20261):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-04 15:23:51.961: D/,myapp(20261):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-04 15:23:51.961: D/,myapp(20261):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-04 15:23:51.961: D/,myapp(20261):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-04 15:23:51.961: D/,myapp(20261):    at java.lang.Thread.run(Thread.java:856)

在服务器端,消息为:

at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499) 
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) 
at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293) 
at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:228) 
at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:198) 
at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProcessor.java:45) 
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:485) 
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
at java.lang.Thread.run(Thread.java:679) 
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? 
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:171) 
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:814) 
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:727) 
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624) 
at org.apache.mina.filter.support.SSLHandler.unwrap0(SSLHandler.java:658) 
at org.apache.mina.filter.support.SSLHandler.unwrapHandshake(SSLHandler.java:614) 
at org.apache.mina.filter.support.SSLHandler.handshake(SSLHandler.java:493) 
at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:306) 
at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392) 
... 14 more 
2013.06.04 14:16:32 org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /184.151.127.182:33096, L: /66.228.58.218:5223, S: 0.0.0.0/0.0.0.0:5223)

我尝试在连接配置中使用不同的设置,例如使用安全模式。我也尝试过给它一个callbackhandler,但是从未调用过。

编辑:启用调试后我得到了这个:

06-05 09:22:20.044: D/SMACK(7597): 09:22:20 AM SENT (1106505464): <stream:stream to="coffeemobile.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
06-05 09:22:20.084: D/SMACK(7597): 09:22:20 AM SENT (1106505464): </stream:stream>

1 个答案:

答案 0 :(得分:4)

通过从ConnectionConfiguration中删除端口号来解决此问题。