.connect() directly (without 500ms delay) after new Strophe.Connection get stuck @ authenticating
bobwolff68 opened this issue · comments
The symptom: Strophe connection emits a 'connecting' and an 'authenticating' but never makes it to 'connected'. (Sometimes - of course)
The system setup -- server is OpenFire 3.7.1. BOSH is done via bosh-server (node.js) by Dhruv Matani.
Both running on an Amazon ec2 server.
Connection of clients is ANONYMOUS -- 'id' is 'servername' and password is "".
Clients we're using to develop on are Macs primarily. I've replicated this problem on Firefox and Chrome but use Chrome almost exclusively in test-dev. Chrome is Version 19.0.1084.56.
Strophe being used says "1.0.2" in Strophe.VERSION
Here's a snippet of console messages showing what happens in terms of the status callback and the associated callback function itself. Lines in bold are the status callback messages (I've done the bold in this message for clarity)
11:35:56 INFO fb load facebook-jssdk index.js:35
XMPP/Strophe Connecting... callcast.js:1344
11:35:56 INFO Page loaded. index.js:35
11:35:56 INFO fbAsyncInit callback index.js:35
XMPP/Strophe Authenticating... callcast.js:1342
11:35:56 INFO authResponseChange callback index.js:35
FB logged IN or got a new token. fb.js:53
11:35:56 INFO fbLoginStatus callback response.authResponse[object Object] index.js:35
11:35:56 INFO checkCredentials index.js:35
one-login-complete: Msg: checkCredentials - FB Login
conn_callback: function(status) {
if (status === Strophe.Status.CONNECTED) {
console.log("Finalizing connection and then triggering connected...");
Callcast.finalizeConnect();
$(document).trigger('connected');
} else if (status === Strophe.Status.AUTHENTICATING) {
console.log("XMPP/Strophe Authenticating...");
} else if (status === Strophe.Status.CONNECTING) {
console.log("XMPP/Strophe Connecting...");
} else if (status === Strophe.Status.ATTACHED) {
console.log("Re-Attach of connection successful. Triggering re-attached...");
$(document).trigger('re-attached');
} else if (status === Strophe.Status.DISCONNECTED) {
console.log("XMPP/Strophe Disconnected.");
Callcast.disconnect();
$(document).trigger('disconnected');
} else if (status === Strophe.Status.DISCONNECTING) {
console.log("XMPP/Strophe is Dis-Connecting...should we try to re-attach here? TODO:RMW");
} else if (status === Strophe.Status.CONNFAIL) {
console.log("XMPP/Strophe reported connection failure...attempt to re-attach...");
Callcast.reattach(Callcast.connection.jid, Callcast.connection.sid, Callcast.connection.rid, Callcast.conn_callback);
alert("NOTICE -- attempted to auto-re-attach after connection failure. Did we succeed?");
} else if (status === Strophe.Status.AUTHFAIL) {
Callcast.disconnect();
$(document).trigger('disconnected');
alert("Authentication failed. Bad password or username.");
}
else
console.log("Strophe connection callback - unhandled status = " + status);
},
And here's the function which setups up the connection. I can do this with or without the .reset() and it'll fail with the same general frequency. NOTE: This is an anonymous authentication: id='servername' and pw="" while url is null
connect: function(id, pw, url) {
var self = this;
var boshconn = "/xmpp-httpbind";
if (url)
boshconn = url;
/* Withor without this section fails...
if (this.connection)
{
this.disconnect();
this.reset();
delete this.connection;
}
*/
this.connection = new Strophe.Connection(boshconn);
// with or without this it fails too this.connection.reset();
this.connection.connect(id, pw, self.conn_callback);
},
Now -- to make it work reliably....put in a timer for the .connect()
var self = this;
this.connection = new Strophe.Connection(boshconn);
// with or without this it fails too this.connection.reset();
setTimeout(function() {
self.connection.connect(id, pw, self.conn_callback);
}, 500);
Found the answer to this issue myself. I had an asynchronous event which when it triggered, would cause me to send my presence information "if (this.connection)". The problem...the connection existed and was even connected, but it was not authenticated and so presence information was being injected into the stream during the SASL negotiation. The proper answer was to say "if (this.connection && this.connection.connected && this.connection.authenticated) ..."
Hi,
I am stuck with same after installing node vesion 4.2.3. Before that on node version 0.10.13 this was working fine. I am using dependency module version "jsdom": "5.6.1", "xmlhttprequest": "1.8.0".
I have installed openfire version Openfire 3.10.3 on my localhost.
Following is my error log
show status: 1
Connecting
SENT:
RECV: stream:featuresDIGEST-MD5PLAINANONYMOUSCRAM-MD5/stream:features
show status: 3
Authenticating
SENT:
show status: 7
Disconnecting
show status: 6
Disconnected
Also when I use javascript strophe.js library and run through browser this work fine so may be the problem with node-strophe or it's dependency module jsdom, xmlhttprequest.
Please suggest.