0

我正在使用 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。

4

2 回答 2

0

看来 Openfire v3.9.3 BOSH 实现很“古怪”。MatriX 开发人员能够解决这个问题。从 MatriX v1.6.0.1 开始,该场景已解决。

于 2014-09-18T17:50:25.857 回答
0

通常,当您连接到 BOSH 连接管理器时,您可以在wait第一节(会话创建请求)上设置属性。

XEP-0124 会话创建响应

Strophe 和 Candy 使用的默认值为60. 您能否确认 MatriX 在建立 BOSH 会话时使用的值?

前任:

<body content='text/xml; charset=utf-8'
  from='user@example.com'
  hold='1'
  rid='1573741820'
  to='example.com'
  route='xmpp:example.com:9999'
  wait='60'
  xml:lang='en'
  xmpp:version='1.0'
  xmlns='http://jabber.org/protocol/httpbind'
  xmlns:xmpp='urn:xmpp:xbosh'/>
于 2014-09-17T18:37:05.813 回答