Pergunta

Ao enviar o pacote para o OpenFire usando o Smack, recebo erros remotos-server-não-acordados (404). Alguém pode explicar o que significa o erro? Isso significa que não se conecta ao servidor ou o pacote tem problemas?

        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());
        }

// --- Abaixo está como eu me conecto ao 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");

Anexei o XMPP XML que recebi do log

enviando ....

<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>

receber....

<?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>test@xuser/god</jid></bind></iq>
<iq type="result" id="CHWuJ-1" to="test@xuser/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="test@xuser/god"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"/></query></iq>
<iq type="error" id="CHWuJ-4" to="test@xuser/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>

Inteprendeu ..

<iq id="CHWuJ-0" to="xuser/d0689fdf" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>test@xuser/god</jid></bind></iq>
<iq id="CHWuJ-1" to="test@xuser/god" type="result"></iq>
<iq id="CHWuJ-2" to="test@xuser/god" type="result"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"></item></query></iq>
<iq id="CHWuJ-4" to="test@xuser/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>
Foi útil?

Solução

Este erro é gerado pelo servidor (veja Xmpperror). Eu tentei obter exatamente o mesmo código de erro, mas falhei. No entanto, tenho a sensação de que isso é uma configuração incorreta do servidor. Você tentou se conectar com outro cliente, por exemplo, usando seu cliente de jabber favorito?

Você também pode tentar ativar o recurso Smacks XMPP Debugging e postar as mensagens que causaram o erro:

static {
    XMPPConnection.DEBUG_ENABLED = true;
}

(Você também pode querer adicionar smackx-debug.jar para obter ainda mais recursos de depuração)

Outras dicas

Encontrei um problema semelhante que resolvi recentemente.

Eu tenho um servidor OpenFire em execução no meu computador local e estou usando a API SMACK para me comunicar com o servidor. No OpenFire, eu defini dois usuários: remetente e receptor. Não usei endereços de email para nomes de usuário.

No meu código, tenho uma conexão para "remetente" em um thread e uma conexão para "receptor" em um thread separado. Inicialmente, ao enviar mensagens, recebi remote-server-not-found(404) Respostas de erro do servidor OpenFire. Descobri que, ao criar o pedido de bate -papo pelo remetente, eu precisava definir o participante como receiver@[Openfire domain].

Então, se o seu domínio OpenFire for foo, seria receiver@foo. Obviamente, este não é o endereço de e -mail do usuário "receptor". Normalmente, o domínio é realmente apenas o nome da máquina na qual o servidor OpenFire está em execução.

Verifique se o pacote é enviado para o usuário certo!

Você deve definir um Jid válido para o atributo "to" do pacote de QI, para que o servidor possa enviar o pacote para o receptor. Recebi esse erro antes porque eu defino o jid errado para o pacote.

BTW, você pode adicionar xmppConnection.debug_enabled = true em seu código para ver o que você enviou ou procure o login de erro no console da web openfire, e você pode encontrar algum erro como este: erro tentando conectar ao servidor remoto: thewroghost (pesquisa DNS: TheWronshost: 5269)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top