无法连接到Openfire的服务器(使用咂嘴API) [英] Unable to connect to Openfire server (using smack api)

查看:3140
本文介绍了无法连接到Openfire的服务器(使用咂嘴API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行使用此code嫌4.1.0

 发D =新主题(新的Runnable(){

            @覆盖
            公共无效的run(){
                SmackConfiguration.setDefaultPacketReplyTimeout(10000);
                XMPPTCPConnectionConfiguration配置= XMPPTCPConnectionConfiguration.builder()
                        .setUsernameAndPassword(苛刻,通行证)
                        .setServiceName(192.168.0.200)
                        .setHost(192.168.0.200)
                        .setPort(5223).setSecurityMode(ConnectionConfiguration.SecurityMode.ifpossible)
                        。建立();

                AbstractXMPPConnection CONN2 =新XMPPTCPConnection(配置);
                尝试 {
                    conn2.connect();

                    conn2.login();

                    presence presence =新的presence(presence.Type.unavailable);
                    presence.setStatus(去钓鱼);
                    //发送数据包(假设有一个叫骗子的XMPPConnection实例)。
                    conn2.sendStanza(presence);

                }赶上(SmackException | IOException异常| XMPPException E){
                    // TODO自动生成的catch块
                    e.printStackTrace();
                    Log.d(TAG,e.toString());
                }

                ChatManager chatmanager = ChatManager.getInstanceFor(CONN2);


                聊天newChat = chatmanager.createChat(harsh@192.168.0.200);

                尝试 {
                    newChat.sendMessage(你好!);
                }
                赶上(SmackException.NotConnectedException E){
                    // TODO自动生成的catch块
                    e.printStackTrace();
                }



            }
        });





        D.start();


    }
 

这给了我一个错误:

  05-15 14:59:35.350 4417-4439 / com.example.smacktester W / System.err的:org.jivesoftware.smack.SmackException $ NoResponseException:内回复没有收到任何答复时间到。超时为10000ms(〜10秒)。二手过滤:无过滤器使用或过滤器是零。 05-15 14:59:35.351 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoint.java:192)05-15 14:59:35.352 4417- 4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(SynchronizationPoint.java:114)05-15 14:59:35.352 4417-4439 / com.example.smacktester W /系统.ERR:在org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWaitOrThrow(SynchronizationPoint.java:97) 05-15 14:59:35.352 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:837)05-15 14:59:35.352 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:360)05-15 14:59:35.354 4417-4439 / com.example.smacktesterW¯¯ /System.err:在com.example.smacktester.MainActivity $ 1.运行(MainActivity.java:50)05-15 14:59:35.354 4417-4439 / com.example.smacktester W / System.err的:在java.lang中.Thread.run(Thread.java:818)05-15 14:59:35.355 4417-4439 / com.example.smacktester D / TAG:org.jivesoftware.smack.SmackException $ NoResponseException:没有内回复超时收到的响应。超时为10000ms(〜10秒)。二手过滤:无过滤器使用或过滤器是零。 05-15 14:59:35.365 4417-4444 / com.example.smacktester W / AbstractXMPPConnection:错误连接关闭
    org.xmlpull.v1.XmlPullParserException:意外令牌(位置:TEXT 2P @ 1:8 java.io.BufferedReader@16ea33d4)
            在org.kxml2.io.KXmlParser.next(KXmlParser.java:432)
            在org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
            在org.jivesoftware.smack.tcp.XMPPTCPConnection $ PacketReader.parsePackets(XMPPTCPConnection.java:1151)
            在org.jivesoftware.smack.tcp.XMPPTCPConnection $ PacketReader.access $ 200(XMPPTCPConnection.java:937)
            在org.jivesoftware.smack.tcp.XMPPTCPConnection $ PacketReader $ 1.运行(XMPPTCPConnection.java:952)
            在java.lang.Thread.run(Thread.java:818)05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:org.jivesoftware.smack.SmackException $ NotConnectedException:客户是没有或更长的时间,连接05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExceptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1226) 05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfAppropriate(XMPPTCPConnection.java:336) 05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection.java:609)05-15 14:59:35.377 4417- 4439 / com.example.smacktester W / System.err的:在org.jivesoftware.smack.chat.ChatManager.sendMessage(ChatManager.java:365)05-15 14:59:35.377 4417-4439 / com.example.smacktesterW¯¯ /System.err:在org.jivesoftware.smack.chat.Chat.sendMessage(Chat.java:114)05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在有机jivesoftware.smack.chat.Chat.sendMessage(Chat.java:98)05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在com.example.smacktester.MainActivity $ 1.运行(MainActivity.java:71)05-15 14:59:35.377 4417-4439 / com.example.smacktester W / System.err的:在java.lang.Thread.run(Thread.java:818)05-15 14: 59:56.335 4417-4417 / com.example.smacktester I /时间线:时间线:Activity_idle ID:android.os.BinderProxy@2763795b时间:38739229 05-15 15:00:19.772 4417-4427 / com.example.smacktester W /艺术:暂停所有线程了:
10.531ms 05-15 15:02:44.503 4417-4427 / com.example.smacktester W /艺术:暂停所有线程接过:7.832ms
 

,并在当地的Openfire服务器启用调试完毕后,我得到这个消息:

  2015年5月15日14时五十分03秒的index.jsp  - 无法抓取RSS提要:javax.net.ssl​​.SSLHandshakeException:java.security.cert.CertificateException:根证书不被信任对[vanity2.jiveon.com]
 

我在哪里去了?

解决方案

按照与默认客户端在XMPPTCPConnectionConfiguration .Port 5223用户的问题是 .setPort(5223)讨论SSL端口中的Openfire,

 你可以改变从管理面板中的Openfire 3.10这个端口设置
 

  

服务器>>服务器设置>>客户端连接

错误

  

org.jivesoftware.smack.SmackException $ NoResponseException:无回应   在响应超时接收。超时为10000ms(〜10秒)。

意味着你正在试图连接启用SSL端口[5223]与出做SASL协商。 意味着你需要存储在应用程序[在内部/外部存储一些地方]提供XMPP服务器[Opnefire] SSL证书,并使用相同的证书与SSL端口XMPP服务器进一步沟通。

  

有关SSL认证,您可以用户的<一个href="http://stackoverflow.com/questions/24819441/certpathvalidatorexception-trust-anchor-for-certification-path-not-found-wit/26360672#26360672">Truststore

     

有关XMPP SASL协商的详细信息,请参阅此链接

I am trying to run this code using smack 4.1.0

 Thread D= new Thread(new Runnable() {

            @Override
            public void run() {
                SmackConfiguration.setDefaultPacketReplyTimeout(10000);
                XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                        .setUsernameAndPassword("harsh", "pass")
                        .setServiceName("192.168.0.200")
                        .setHost("192.168.0.200")
                        .setPort(5223).setSecurityMode(ConnectionConfiguration.SecurityMode.ifpossible)
                        .build();

                AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
                try {
                    conn2.connect();

                    conn2.login();

                    Presence presence = new Presence(Presence.Type.unavailable);
                    presence.setStatus("Gone fishing");
                    // Send the packet (assume we have an XMPPConnection instance called "con").
                    conn2.sendStanza(presence);

                } catch (SmackException | IOException | XMPPException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Log.d("TAG", e.toString());
                }

                ChatManager chatmanager = ChatManager.getInstanceFor(conn2);


                Chat newChat = chatmanager.createChat("harsh@192.168.0.200");

                try {
                    newChat.sendMessage("Howdy!");
                }
                catch (SmackException.NotConnectedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }



            }
        });





        D.start();


    }

This gives me an error :

05-15 14:59:35.350    4417-4439/com.example.smacktester W/System.err﹕ org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Used filter: No filter used or filter was 'null'. 05-15 14:59:35.351    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoint.java:192) 05-15 14:59:35.352    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(SynchronizationPoint.java:114) 05-15 14:59:35.352    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWaitOrThrow(SynchronizationPoint.java:97) 05-15 14:59:35.352    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:837) 05-15 14:59:35.352    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:360) 05-15 14:59:35.354    4417-4439/com.example.smacktester W/System.err﹕ at com.example.smacktester.MainActivity$1.run(MainActivity.java:50) 05-15 14:59:35.354    4417-4439/com.example.smacktester W/System.err﹕ at java.lang.Thread.run(Thread.java:818) 05-15 14:59:35.355    4417-4439/com.example.smacktester D/TAG﹕ org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Used filter: No filter used or filter was 'null'. 05-15 14:59:35.365    4417-4444/com.example.smacktester W/AbstractXMPPConnection﹕ Connection closed with error
    org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT ��P@1:8 in java.io.BufferedReader@16ea33d4)
            at org.kxml2.io.KXmlParser.next(KXmlParser.java:432)
            at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1151)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
            at java.lang.Thread.run(Thread.java:818) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExceptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1226) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfAppropriate(XMPPTCPConnection.java:336) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection.java:609) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.chat.ChatManager.sendMessage(ChatManager.java:365) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.chat.Chat.sendMessage(Chat.java:114) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at org.jivesoftware.smack.chat.Chat.sendMessage(Chat.java:98) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at com.example.smacktester.MainActivity$1.run(MainActivity.java:71) 05-15 14:59:35.377    4417-4439/com.example.smacktester W/System.err﹕ at java.lang.Thread.run(Thread.java:818) 05-15 14:59:56.335    4417-4417/com.example.smacktester I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@2763795b time:38739229 05-15 15:00:19.772   4417-4427/com.example.smacktester W/art﹕ Suspending all threads took:
10.531ms 05-15 15:02:44.503    4417-4427/com.example.smacktester W/art﹕ Suspending all threads took: 7.832ms

And, after enabling debugging in the local openfire server, I get this message:

2015.05.15 14:50:03 index.jsp - Failed to fetch RSS feed: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: root certificate not trusted of [vanity2.jiveon.com]

Where am I going wrong ?

解决方案

AS per discussion with user problem was .setPort(5223) in XMPPTCPConnectionConfiguration .Port 5223 by default Client SSL Port in Openfire,

you can change this port setting in  Openfire 3.10 from Admin panel 

Server >> Server Settings >> Client Connections

error

org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s).

Means You are trying to connecting SSL enabled port [5223] with out doing SASL negotiation. Means you need to Store SSL certificate provided by XMPP server[Opnefire] in your application[some where in your internal/external memory] ,and use same certificate for further communication with Xmpp server on SSL Port.

For SSL authentication you can user Truststore

For more information on XMPP SASL negotiation refer this link

这篇关于无法连接到Openfire的服务器(使用咂嘴API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆