Candy.js (v1.7.1) と Openfire v3.9.3 を使用しています。Candy パッケージに含まれているサンプルの index.html を実行すると、直接認証 (jid/pwd のブラウザー プロンプト) を使用しても問題はありません。ただし、サンプルを変更して Candy.Core.attach (Strophe.Connection.attach へのほぼパススルー) を使用するように変更すると、サーバー側の事前バインド (MatriX を使用) を実行した後、ある種のアイドル ループに陥ってしまうようです。空のメッセージを XMPP サーバーに 1 秒間に 3 回送信します。
このループの原因と、Candy.Core.attach を使用するとデモの Candy UI が表示されない理由を教えてください。
修正サンプル...
$(document).ready(function() {
var httpbindUrl = 'http://xmpp.mydomain.net:7070/http-bind/';
var chatRoom = 'testroom@conference.mydomain.net';
// These values come from a REST call to our services that perform
// the prebind authentication (using MatriX, obviously)
var jid = 'someuser@mydomain.net/MatriX';
var sid = 'b95ffa4'; // must be a string despite what candy's doc say
var rid = 1983626985;
Candy.init(httpbindUrl, {
core: {
debug: true,
autojoin: [chatRoom]
},
view: { assets: './res/' }
});
Candy.Core.attach(jid, sid, rid); // this seems to cause some sort of looping to occur
// Candy.Core.connect('someuser@mydomain.net', 'password'); // <-- this works as expected
});
ブラウザのコンソール ログが表示されます...
POST http://xmpp.mydomain.net:7070/http-bind/ [HTTP/1.1 200 OK 895ms]
POST http://xmpp.mydomain.net:7070/http-bind/ [HTTP/1.1 200 OK 491ms]
POST http://xmpp.mydomain.net:7070/http-bind/ [HTTP/1.1 200 OK 483ms]
"RECV: <body xmlns='http://jabber.org/protocol/httpbind' ack='1983626985'/>" candy.bundle.js:159
"LIBS:<1>: no requests during idle cycle, sending blank request" libs.bundle.js:1192
"LIBS:<0>: request id 4.0 posting" libs.bundle.js:1192
"LIBS:<0>: request id 4.0 state changed to 1" libs.bundle.js:1192
"SENT: <body rid='1983626986' xmlns='http://jabber.org/protocol/httpbind' sid='b95ffa4'/>" candy.bundle.js:159
POST http://xmpp.mydomain.net:7070/http-bind/ [HTTP/1.1 200 OK 436ms]
"LIBS:<0>: request id 4.1 state changed to 2" libs.bundle.js:1192
"LIBS:<0>: request id 4.1 state changed to 3" libs.bundle.js:1192
"LIBS:<0>: request id 4.1 state changed to 4" libs.bundle.js:1192
"LIBS:<0>: removing request" libs.bundle.js:1192
"LIBS:<0>: _throttledRequestHandler called with 0 requests" libs.bundle.js:1192
"LIBS:<0>: request id 4 should now be removed" libs.bundle.js:1192
"LIBS:<0>: request id 4.1 got 200" libs.bundle.js:1192
"LIBS:<1>: _dataRecv called" libs.bundle.js:1192
"RECV: <body xmlns='http://jabber.org/protocol/httpbind' ack='1983626986'/>" candy.bundle.js:159
"LIBS:<1>: no requests during idle cycle, sending blank request" libs.bundle.js:1192
"LIBS:<0>: request id 5.0 posting" libs.bundle.js:1192
"LIBS:<0>: request id 5.0 state changed to 1" libs.bundle.js:1192
"SENT: <body rid='1983626987' xmlns='http://jabber.org/protocol/httpbind' sid='b95ffa4'/>" candy.bundle.js:159
...continues in a similar pattern until I close the browser window.
注: 「LIBS:」で始まるエントリは、strophe の低レベル ログ (レベル、msg) からのものです。candy のデモでは、strophe.js が libs.bundle.js という大きなバンドルにラップされていることにも注意してください。