I use Strophe.Connection to create and initialize a Strophe.Connection object and I start the connection process with 'connect' function but it return ATTACHED status instead of CONNECTED as expected in the book.
This code come from the Jack Moffitt 'Professional XMPP programming with JavaScript and JQuery" but it doesn't work for me :-(
- It's same with both Openfire and eJabberd server
- It's same when configuring Apach to proxy BOSH
- It's same with a test server at http://bosh.metajack.im:5280/xmpp-httpbind
- BOSH status is ok when entering http://localhost:5280/http-bind or http://localhost:5280/xmpp-httpbind
I've passed the all day on it and I'm getting big headache. Any help would be appreciate. Thank you,
Here is the code :
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection(
"http://localhost:5280/xmpp-httpbind");
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
$(document).trigger('disconnected');
}
});
In order to understand what is going on I've modified the code as this (with the connect status):
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection(
"http://localhost:5280/xmpp-httpbind");
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
$(document).trigger('disconnected');
} else if (status === Strophe.Status.ERROR) {
alert ('status ERROR');
} else if (status === Strophe.Status.CONNECTING) {
alert ('status CONNECTING');
} else if (status === Strophe.Status.CONNFAIL) {
alert ('status CONNFAIL');
} else if (status === Strophe.Status.AUTHENTICATING) {
alert ('status AUTHENTICATING');
} else if (status === Strophe.Status.AUTHFAIL) {
alert ('status AUTHFAIL');
} else if (status === Strophe.Status.ATTACHED);
alert ('status ATTACHED');
It show me two status : CONNECTING then ATTACHED. Why I can not have CONNECTED status as expected in the book ???