2013-02-16 87 views
3

我想連接通過的strophe到xmmp,我已經配置了什麼XMPP和的strophe

我使用WAMP我的系統上運行本地主機PHP的

我在Openfire的管理

我啓用了腳本語法已配置Apache的httpd.conf到

# XMPP proxy rule 
ProxyRequests Off 
ProxyPass /xmpp-httpbind http://127.0.0.1:7070/http-bind/ 
ProxyPassReverse /xmpp-httpbind http://127.0.0.1:7070/http-bind 

而且我使用基本的JavaScript文件瞬移到服務器,所以代碼放在這裏

var BOSH_SERVICE = '/xmpp-httpbind' 
var connection = null; 

function log(msg) 
{ 
    $('#log').append('<div></div>').append(document.createTextNode(msg)); 
} 

function rawInput(data) 
{ 
    log('RECV: ' + data); 
} 

function rawOutput(data) 
{ 
    log('SENT: ' + data); 
} 

function onConnect(status) 
{ 
    if (status == Strophe.Status.CONNECTING) { 
    log('Strophe is connecting.'); 
    } else if (status == Strophe.Status.CONNFAIL) { 
    log('Strophe failed to connect.'); 
    $('#connect').get(0).value = 'connect'; 
    } else if (status == Strophe.Status.DISCONNECTING) { 
    log('Strophe is disconnecting.'); 
    } else if (status == Strophe.Status.DISCONNECTED) { 
    log('Strophe is disconnected.'); 
    $('#connect').get(0).value = 'connect'; 
    } else if (status == Strophe.Status.CONNECTED) { 
    log('Strophe is connected.'); 
    connection.disconnect(); 
    } 
} 

$(document).ready(function() { 
    connection = new Strophe.Connection(BOSH_SERVICE); 
    connection.rawInput = rawInput; 
    connection.rawOutput = rawOutput; 

    $('#connect').bind('click', function() { 
    var button = $('#connect').get(0); 
    if (button.value == 'connect') { 
     button.value = 'disconnect'; 

     connection.connect($('#jid').get(0).value, 
        $('#pass').get(0).value, 
        onConnect); 
    } else { 
     button.value = 'connect'; 
     connection.disconnect(); 
    } 
    }); 
}); 

當我想用 「[email protected]」 連接,我做AUTHFAIL,甚至用 「管理員」 後,我得到這樣的響應:

JID:密碼:

Strophe is connecting. 
SENT: <body rid='1613006691' xmlns='http://jabber.org/protocol/httpbind' to='admin' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams' authid='2ff1799d' sid='2ff1799d' secure='true' requests='2' inactivity='30' polling='5' wait='60' hold='1' ack='1613006691' maxpause='300' ver='1.6'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><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></body> 
SENT: <body rid='1613006692' xmlns='http://jabber.org/protocol/httpbind' sid='2ff1799d'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/></body> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/></body> 
SENT: <body rid='1613006693' xmlns='http://jabber.org/protocol/httpbind' sid='2ff1799d' to='admin' xml:lang='en' xmpp:restart='true' xmlns:xmpp='urn:xmpp:xbosh'/> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams'><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></body> 
SENT: <body rid='1613006694' xmlns='http://jabber.org/protocol/httpbind' sid='2ff1799d'><iq type='set' id='_bind_auth_2' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></iq></body> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client' type='result' id='_bind_auth_2' to='pedram-pc/2ff1799d'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>[email protected]/2ff1799d</jid></bind></iq></body> 
SENT: <body rid='1613006695' xmlns='http://jabber.org/protocol/httpbind' sid='2ff1799d'><iq type='set' id='_session_auth_2' xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq></body> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client' type='result' id='_session_auth_2' to='[email protected]/2ff1799d'/></body> 
Strophe is connected. 
Strophe is disconnecting. 
SENT: <body rid='1613006696' xmlns='http://jabber.org/protocol/httpbind' sid='2ff1799d' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body> 
RECV: <body xmlns='http://jabber.org/protocol/httpbind'/> 
Strophe is disconnected. 

我的問題在哪裏?

回答

1

你的日誌顯示:

Strophe is connected. 
Strophe is disconnecting. 

您的代碼表示:

} else if (status == Strophe.Status.CONNECTED) { 
log('Strophe is connected.'); 
connection.disconnect(); 
} 

所以......它看起來像一切都被配置蠻好的,只是立即代碼斷開連接,一旦連接成功...