I am trying to run this code using smack 4.1.0
我正在尝试使用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:
在本地openfire服务器上启用调试后,我得到以下消息:
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 ?
我哪里出错了?
1 个解决方案
#1
4
AS per discussion with user problem was .setPort(5223)
in XMPPTCPConnectionConfiguration .Port 5223 by default Client SSL Port in Openfire,
根据与用户问题的讨论,XMPPTCPConnectionConfiguration中的.setPort(5223) .Port 5223在Openfire中的默认客户端SSL端口,
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).
org.jivesoftware.smack。SmackException$NoResponseException:在应答超时内没有收到响应。超时是10000 ms(~ 10 s)。
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.
意味着您正在尝试连接启用SSL的端口[5223],而不进行SASL协商。意味着您需要将XMPP服务器[Opnefire]提供的SSL证书存储在应用程序中[一些存储在您的内部/外部内存中],并使用相同的证书在SSL端口上与XMPP服务器进行进一步通信。
For SSL authentication you can user Truststore
对于SSL身份验证,可以使用Truststore
For more information on XMPP SASL negotiation refer this link
有关XMPP SASL协商的更多信息,请参考此链接
#1
4
AS per discussion with user problem was .setPort(5223)
in XMPPTCPConnectionConfiguration .Port 5223 by default Client SSL Port in Openfire,
根据与用户问题的讨论,XMPPTCPConnectionConfiguration中的.setPort(5223) .Port 5223在Openfire中的默认客户端SSL端口,
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).
org.jivesoftware.smack。SmackException$NoResponseException:在应答超时内没有收到响应。超时是10000 ms(~ 10 s)。
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.
意味着您正在尝试连接启用SSL的端口[5223],而不进行SASL协商。意味着您需要将XMPP服务器[Opnefire]提供的SSL证书存储在应用程序中[一些存储在您的内部/外部内存中],并使用相同的证书在SSL端口上与XMPP服务器进行进一步通信。
For SSL authentication you can user Truststore
对于SSL身份验证,可以使用Truststore
For more information on XMPP SASL negotiation refer this link
有关XMPP SASL协商的更多信息,请参考此链接