我正在使用 Candy.js (v1.7.1) 和 Openfire v3.9.3。运行 Candy 包中包含的示例 index.html,我没有问题(浏览器提示输入 jid/pwd)。但是,如果我在执行服务器端预绑定(uisng MatriX)之后将示例更改为使用 Candy.Core.attach(几乎是 Strophe.Connection.attach 的直通),我似乎陷入了某种空闲循环每秒向 XMPP 服务器发送 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 的低级日志记录(级别、味精)。还应该注意的是,糖果演示将 strophe.js 包装成一个更大的包,称为 libs.bundle.js。