XMPP and Strophe

I want to connect to xmmp via Strophe, I configured something

I am using WAMP on my system to run localhost php

I have enabled Script syntax in openfire admin

I have configured APACHE httpd.conf to

# 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

      

Also I am using the main javascript file to connect to the server, so the code goes here

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

      

When I want to connect to " admin@127.0.0.1 " I do AUTHFAIL, even after using "admin" I get this response:

JID: Password:

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>2ff1799d@pedram-pc/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='2ff1799d@pedram-pc/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.

      

Where is my problem?

+3


source to share


1 answer


Your log shows:

Strophe is connected.
Strophe is disconnecting.

      

Your code says:



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

      

So ... it looks like everything is set up just fine, and your code disconnects immediately after a successful connection ...

+1


source







All Articles