2012-07-29 106 views
5

我有一臺openfire服務器設置在我的本地機器上。我試圖連接這個服務器,但得到「服務器沒有響應」錯誤。不知道爲什麼?Smack「服務器無響應」。不知道爲什麼我得到這個錯誤

我在成功連接到服務器的同一臺計算機上產生了spark客戶端。

你能幫我解決問題嗎?

下面是日誌的詳細信息,可以幫助

07-30 01:01:02.570: I/System.out(424): 01:01:02 AM SENT (1156489960): <stream:stream to="192.168.1.3"    xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
07-30 01:01:02.593: I/System.out(424): 01:01:02 AM RCV (1156489960): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from= 
07-30 01:01:02.593: I/System.out(424): 01:01:02 AM RCV (1156489960): "praleeds" id="39bc1246" xml:lang="en" version="1.0"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></startt 
07-30 01:01:02.593: I/System.out(424): 01:01:02 AM RCV (1156489960): ls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism> 
07-30 01:01:02.593: I/System.out(424): 01:01:02 AM SENT (1156489960): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
07-30 01:01:02.617: I/System.out(424): 01:01:02 AM RCV (1156489960): ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><metho 
07-30 01:01:02.617: I/System.out(424): 01:01:02 AM RCV (1156489960): d>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-re 
07-30 01:01:02.623: I/System.out(424): 01:01:02 AM RCV (1156489960): gister"/></stream:features><proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
07-30 01:01:02.835: W/System.err(424): java.security.KeyStoreException: KeyStore jks implementation not found 
07-30 01:01:02.835: W/System.err(424): at java.security.KeyStore.getInstance(KeyStore.java:134) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:61) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:839) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:268) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71) 
07-30 01:01:11.612: W/ActivityManager(59): Launch timeout has expired, giving up wake lock! 
07-30 01:01:12.038: W/ActivityManager(59): Activity idle timeout for HistoryRecord{45072328 com.android.notifications/.NotificationsActivity} 
07-30 01:01:17.284: D/dalvikvm(235): GC_EXPLICIT freed 156 objects/11400 bytes in 228ms 
07-30 01:01:17.653: I/System.out(424): 01:01:17 AM SENT (1156489960): <iq id="Q41Dw-0" to="praleeds" type="set"><query xmlns="jabber:iq:register"><password>praleed</password><email>[email protected]</email><username>praleedsuvarna</username><name>Praleed Suvarna</name></query></iq> 
07-30 01:01:22.344: D/dalvikvm(260): GC_EXPLICIT freed 45 objects/2176 bytes in 239ms 
07-30 01:01:22.693: V/Praleed-Notifications(424): No Response from Server; Host : 192.168.1.3; User : null 
07-30 01:01:22.924: I/ActivityManager(59): Displayed activity com.android.notifications/.NotificationsActivity: 21292 ms (total 21292 ms) 
07-30 01:01:23.545: I/global(424): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required. 
07-30 01:01:23.545: I/global(424): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required. 
07-30 01:01:23.553: I/System.out(424): 01:01:23 AM SENT (1156489960): <stream:stream to="praleeds" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
07-30 01:01:23.573: I/System.out(424): 01:01:23 AM SENT (1156489960): <presence id="Q41Dw-1" type="unavailable"></presence> 
07-30 01:01:23.573: I/System.out(424): 01:01:23 AM SENT (1156489960): </stream:stream> 
07-30 01:01:23.799: W/System.err(424): java.io.IOException: Read error: Failure in SSL library, usually a protocol error 
07-30 01:01:23.803: W/System.err(424): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeread(Native Method) 
07-30 01:01:23.803: W/System.err(424): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.access$300(OpenSSLSocketImpl.java:55) 
07-30 01:01:23.803: W/System.err(424): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:542) 
07-30 01:01:23.803: W/System.err(424): at java.io.InputStreamReader.read(InputStreamReader.java:275) 
07-30 01:01:23.813: W/System.err(424): at java.io.BufferedReader.fillBuf(BufferedReader.java:155) 
07-30 01:01:23.813: W/System.err(424): at java.io.BufferedReader.read(BufferedReader.java:348) 
07-30 01:01:23.813: W/System.err(424): at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:42) 
07-30 01:01:23.813: W/System.err(424): at org.kxml2.io.KXmlParser.peek(KXmlParser.java:931) 
07-30 01:01:23.813: W/System.err(424): at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:589) 
07-30 01:01:23.813: W/System.err(424): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:333) 
07-30 01:01:23.813: W/System.err(424): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1385) 
07-30 01:01:23.823: W/System.err(424): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:326) 
07-30 01:01:23.823: W/System.err(424): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44) 
07-30 01:01:23.823: W/System.err(424): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71) 

我使用下面的代碼

System.setProperty("smack.debugEnabled", "true"); 
    XMPPConnection.DEBUG_ENABLED = true; 

    ConnectionConfiguration config = new ConnectionConfiguration("192.168.1.3", 5222); 
    Connection connection = new XMPPConnection(config); 
    try { 
     connection.connect(); 
     AccountManager am = connection.getAccountManager(); 
     HashMap<String, String> attributes = new HashMap<String, String>(); 
     attributes.put("username", "xyz"); 
     attributes.put("password", "******"); 
     attributes.put("email", "[email protected]"); 
     attributes.put("name", "xyz"); 

     am.createAccount("xyz", "******", attributes); 
    } 

在此先感謝。

+0

你可以提供一些代碼如何連接到服務器? – Ali 2012-07-29 20:35:43

+0

嗨阿里,我剛剛編輯我的帖子。感謝您對我的帖子感興趣。 – Prals 2012-07-29 20:45:20

+1

我用'SmackConfiguration.setPacketReplyTimeout(10000);'它的工作。任何人都可以幫助我理解爲什麼我需要增加回復超時時間。請注意服務器安裝在本地機器上。 – Prals 2012-07-29 21:04:08

回答

26

你有沒有注意到的錯誤:

7-30 01:01:02.835: W/System.err(424): java.security.KeyStoreException: KeyStore jks implementation not found 
07-30 01:01:02.835: W/System.err(424): at java.security.KeyStore.getInstance(KeyStore.java:134) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:61) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:839) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:268) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44) 
07-30 01:01:02.835: W/System.err(424): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71) 

確保修復信任的實現!如果你正在使用aSmack例如用

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 
    connectionConfiguration.setTruststoreType("AndroidCAStore"); 
    connectionConfiguration.setTruststorePassword(null); 
    connectionConfiguration.setTruststorePath(null); 
} else { 
    connectionConfiguration.setTruststoreType("BKS"); 
    String path = System.getProperty("javax.net.ssl.trustStore"); 
    if (path == null) 
     path = System.getProperty("java.home") + File.separator + "etc" 
      + File.separator + "security" + File.separator 
      + "cacerts.bks"; 
    connectionConfiguration.setTruststorePath(path); 
} 

Source

+1

謝謝噸流...我實施了你的建議,它幫助我減少了錯誤 – Prals 2012-08-16 21:36:24

+1

非常感謝,你救了我的一天...... – 2013-05-23 11:01:13

+0

@Flow這個代碼我用過,我按照提到的這些步驟在鏈接http://randomizedsort.blogspot.in/2010/09/step-to-step-guide-to-programming.html中,甚至在org.jivesoftware.smack.XMPPConnection.proceedTLSReceived處引發NPE(XMPPConnection.java: 839) – 2014-04-04 06:59:29

7

我增加了回覆超時時間,它像魅力一樣工作。

SmackConfiguration.setPacketReplyTimeout(10000); 

雖然不知道爲什麼我需要做的,所以當被安裝在同一臺機器上的服務器。

相關問題