Question

Im using strophe.js over an openFire server. have used a openConnection something like this.

openConnection: function () {
    //alert("Called.....");
    if (OFConnect.connection != null) return;
    var conn = new Strophe.Connection(OFConnect.xmppHttpBindUrl);
    OFConnect.connection = conn;
    //OFConnect.services = toResource;
    conn.connect(OFConnect.userName + '@' + OFConnect.openfireDomainURL + '/' + OFConnect.classId, OFConnect.password, function (status) {
        alert(status);
        if (status === Strophe.Status.CONNECTED) {
            jQuery(document).trigger('connected');
        } else if (status === Strophe.Status.DISCONNECTED) {
            jQuery(document).trigger('disconnected');
        } else if (status === Strophe.Status.CONNFAIL) {
            alert("XMPP Connection Failed.......");
        } else if (status === Strophe.Status.AUTHENTICATING) {
            alert("XMPP AUTHENTICATING.......");
        } else if (status === Strophe.Status.AUTHFAIL) {
            alert("XMPP AUTHENTICATING Failed......");
        } else if (status === Strophe.Status.ERROR) {
            alert("XMPP ERRROR......");
        } else if (status === Strophe.Status.ATTACHED) {
            jQuery(document).trigger('attached');
        } else if (status === Strophe.Status.CONNFAIL) {}
    });
}
};

Now the problem is that there are some instances where the OPENFIRE SERVER IS DOWN. and i need to do a particular activity if the server is not reachable/down/Incorrect Link . The problem with the above code in this scenario is that it returns Strophe.Status.CONNECTING instead of a connect fail. How do i determine if the link is down.

Please help!!:-(

Was it helpful?

Solution

What version of Strophe are you using?

In 1.0.2, you can probably work around by modifying _doDisconnect() so that it calls this._changeConnectStatus(Strophe.Status.DISCONNECTED, null) unconditionally.

Strophe 1.1.1 seems to do that of the box (just looked at the code, didn't try).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top