Search code examples
openfirestrophepunjab

Not receiving the communication from Openfire Xmpp while connecting throw stropes.js


I am trying to create a client chat. I could able to to see the log of punjab server as Sending - Receiving. But never showing as Strophes Connected Did the following setup

1)Setup an Xmpp server

wget -O openfire.deb http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_3.9.3_all.deb and completed the setup as described in https://www.digitalocean.com/community/tutorials/how-to-install-openfire-xmpp-server-on-a-debian-or-ubuntu-vps Now the openfire is accessble at *****xmppserver.com

2)setup Punjab Bosh Server in the same server By downloading from the github

https://github.com/twonds/punjab/blob/master/INSTALL.txt

and started running by twistd -ny punjab.tac

in etc/hosts added as

127.0.0.1 *****xmppserver.com

3) Finally downloaded latest strophes.js and edited basic.js

var BOSH_SERVICE = 'http://*****xmppserver.com:5280/http-bind';

The output is showing as connecting and never goes to connected!!

function onConnect(status) {
        console.log(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.');
            log('Send a message to ' + connection.jid +
            ' to talk to me.');

            connection.addHandler(onMessage, null, 'message', null, null,  null);
            connection.send($pres().tree());
        }
    }

enter image description here


Solution

  • You can try with the Openfire's built in BOSH http connection manager. Enable it on Openfire's admin panel:
    Server > Server Settings > HTTP Binding, then the BOSH URL should be like

    var BOSH_SERVICE = 'http://*****xmppserver.com:7070/http-bind/';
    

    Putting a / at the end of /http-bind is crucial for Strophe.