2009-10-13 34 views
1

當使用Smack將數據包發送到openfire時,我收到錯誤remote-server-not-found(404)。任何人都可以請解釋這個錯誤是什麼意思?這意味着無法連接到服務器或數據包有問題?openfire smack發送數據包404錯誤的意思是?

 PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID()); 
     PacketCollector response = connection.createPacketCollector(responseFilter); 

     connection.sendPacket(packet); 



     // Wait up to a certain number of seconds for a reply. 
     Packet result = response.nextResult(timeout); 



     // Stop queuing results 
     response.cancel(); 



     if (result == null) { 
      throw new XMPPException("No response from server."); 
     } 
     else if (result.getError() != null) { 

      System.out.println("error:"+result.getError()); //i get error here.... 404 
      throw new XMPPException(result.getError()); 
     } 

// ---下面是如何我不連接到Openfire的。

 ConnectionConfiguration config = new ConnectionConfiguration("localhost", 5222); 
     config.setCompressionEnabled(true); 
     config.setSASLAuthenticationEnabled(true); 



     XMPPConnection connection = new XMPPConnection(config); 
     // Connect to the server 
     connection.connect(); 
     // Log into the server 
     connection.login("test", "test","testresource"); 

我連接,我從日誌

發送接收的XMPP XML ....

<stream:stream to="localhost" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
<stream:stream to="xuser" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
<auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth> 
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Y2hhcnNldD11dGYtOCx1c2VybmFtZT0idGVzdCIscmVhbG09InpoYW5nIixub25jZT0ieHZacDFOdHlkcld6MVBzOFA0UGlnbWgrbHRieWtyclNYU0NLWVJaRyIsbmM9MDAwMDAwMDEsY25vbmNlPSIxdThheGtJSWgrSzhBLzFBSDRtTHJ5OUxDTE1OSFpBa0xvdlVGcVFGIixkaWdlc3QtdXJpPSJ4bXBwL3poYW5nIixtYXhidWY9NjU1MzYscmVzcG9uc2U9MGE3YzEzOWRkODliZjk5NDcxN2ZiNjQzY2E5NWM3ZDUscW9wPWF1dGgsYXV0aHppZD0idGVzdCI=</response> 
<stream:stream to="xuser" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
<iq id="CHWuJ-0" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>god</resource></bind></iq> 
<iq id="CHWuJ-1" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq> 
<compress xmlns='http://jabber.org/protocol/compress'> 
<method>zlib</method></compress> 
<stream:stream to="xuser" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"> 
<iq id="CHWuJ-2" type="get"><query xmlns="jabber:iq:roster"></query></iq> 
<presence id="CHWuJ-3"></presence> 
<iq id="CHWuJ-4" to="pubsub.my.openfire.server" type="set"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node='TestNode2323'/><configure><x xmlns="jabber:x:data" type="submit"><field var="pubsub#persist_items" type="boolean"><value>0</value></field><field var="pubsub#deliver_payloads" type="boolean"><value>1</value></field><field var="pubsub#access_model" type="list-single"><value>open</value></field></x></configure></pubsub></iq> 

接收....

<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="xuser" id="d0689fdf" xml:lang="en" version="1.0"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls> 
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method> 
zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/></stream:features><proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="xuser" id="d0689fdf" xml:lang="en" version="1.0"><stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
<mechanism>PLAIN</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression> 
<auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/></stream:features> 
<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
cmVhbG09InpoYW5nIixub25jZT0ieHZacDFOdHlkcld6MVBzOFA0UGlnbWgrbHRieWtyclNYU0NLWVJaRyIscW9wPSJhdXRoIixjaGFyc2V0PSJ1dGYtOCIsYWxnb3JpdGhtPSJtZDUtc2VzcyI=</challenge> 
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
cnNwYXV0aD1jOWIyOWIxYTMwN2Q5ZjdkYmZiOGM4MDBkMTU4OWFmZQ==</success> 
<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="xuser" id="d0689fdf" xml:lang="en" version="1.0"><stream:features><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features> 
<iq type="result" id="CHWuJ-0" to="xuser/d0689fdf"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>[email protected]/god</jid></bind></iq> 
<iq type="result" id="CHWuJ-1" to="[email protected]/god"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq> 
<compressed xmlns='http://jabber.org/protocol/compress'/> 
<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="xuser" id="d0689fdf" xml:lang="en" version="1.0"><stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features> 
<iq type="result" id="CHWuJ-2" to="[email protected]/god"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"/></query></iq> 
<iq type="error" id="CHWuJ-4" to="[email protected]/god" from="pubsub.my.openfire.server"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node="TestNode2323"/><configure><x xmlns="jabber:x:data" type="submit"><field var="pubsub#persist_items" type="boolean"><value>0</value></field><field var="pubsub#deliver_payloads" type="boolean"><value>1</value></field><field var="pubsub#access_model" type="list-single"><value>open</value></field></x></configure></pubsub><error code="404" type="cancel"><remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 

Intepreted ..

<iq id="CHWuJ-0" to="xuser/d0689fdf" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>[email protected]/god</jid></bind></iq> 
<iq id="CHWuJ-1" to="[email protected]/god" type="result"></iq> 
<iq id="CHWuJ-2" to="[email protected]/god" type="result"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"></item></query></iq> 
<iq id="CHWuJ-4" to="[email protected]/god" from="pubsub.my.openfire.server" type="error"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node='TestNode2323'/><configure xmlns="http://jabber.org/protocol/pubsub"><value>0</value></configure></pubsub><error code="404" type="CANCEL"><remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 
+0

你是如何解決這個問題的? – Hunt 2012-07-31 18:58:01

回答

4

此錯誤由服務器生成(請參閱XMPPError)。我試圖得到完全相同的錯誤代碼,但失敗了。但是,我感覺這是服務器配置錯誤。您是否嘗試連接其他客戶端,例如使用你最喜歡的Jabber客戶端?

您也可以嘗試,使之嫌XMPP調試功能,並張貼導致該錯誤消息:

static { 
    XMPPConnection.DEBUG_ENABLED = true; 
} 

(您可能還需要添加smackx-debug.jar以獲得更多的調試功能)

+0

我添加了調試日誌。 – cometta 2009-10-13 12:09:41

+0

所以這顯然不是一個認證,而是一個pubsub問題。所以你已經能夠自己解決了嗎? – sfussenegger 2009-10-13 12:24:57

2

請檢查數據包是否發送給正確的用戶!

您應該爲iq數據包的「to」屬性設置有效的JID,以便服務器可以將數據包發送給接收方。 之前我得到了這個錯誤,因爲我將錯誤的JID設置爲數據包。

順便說一句,你可以添加XMPPConnection.DEBUG_ENABLED =真在你的代碼,看看你送什麼,或者看錯誤日誌中的Openfire Web控制檯,你可能會發現一些錯誤是這樣的: 錯誤試圖連接到遠程服務器: theWrongHost(DNS查詢:theWrongHost:5269)

5

我遇到了類似的問題,我剛剛解決了。

我在本地計算機上運行Openfire服務器,並且使用Smack API與服務器進行通信。在Openfire中,我定義了兩個用戶:發送者和接收者。我沒有使用電子郵件地址作爲用戶名。

在我的代碼中,我在一個線程上有一個「sender」連接,而在一個單獨的線程上有一個「receiver」連接。最初,在發送消息時,我收到來自Openfire服務器的錯誤響應remote-server-not-found(404)。我發現,在發件人創建聊天請求時,我需要將參與者設置爲[email protected][Openfire domain]

所以,如果您的Openfire域名FOO,這將是[email protected]。顯然,這不是「接收者」用戶的電子郵件地址。通常,域名實際上只是運行Openfire服務器的機器的名稱。

+0

你說得對,我遇到了同樣的問題並解決了。 Tnx – 2012-08-17 09:53:17

+0

我有同樣的問題,但我無法解決它。我使用了[email protected],但我無法解決它。你能幫我嗎 – 2013-03-09 15:05:47

+0

這是怎麼不被標記爲正確的答案?它也解決了我的問題 – Kimutai 2017-03-22 01:48:51

相關問題