糖果/ strophe - 使用预绑定(.attach)导致紧密的空闲循环?

时间:2014-09-17 17:23:18

标签: xmpp openfire strophe bosh candy

我正在使用Candy.js(v1.7.1)和Openfire v3.9.3。运行Candy包中包含的示例index.html,我使用直接身份验证<浏览器提示jid / pwd 没有问题。但是,如果我在执行服务器端预绑定(uisng MatriX)之后将样本更改为使用Candy.Core.attach(几乎是直通Strophe.Connection.attach),我似乎陷入某种空闲循环每秒3次向XMPP服务器发送空消息。

当我使用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)。还应该注意的是,糖果演示将strophe.js包装成一个名为libs.bundle.js的更大的包。

2 个答案:

答案 0 :(得分:0)

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

XEP-0124 Session Creation Response

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'/>

答案 1 :(得分:0)

似乎Openfire v3.9.3 BOSH实施是“古怪的”#39; MatriX开发人员能够解决这个问题。从MatriX v1.6.0.1开始,该方案已得到解决。