Tony
Tony

Reputation: 2066

candy/strophe -- using prebind (.attach) results in tight idle loop?

I'm using Candy.js (v1.7.1) and Openfire v3.9.3. Running the sample index.html included in the Candy package, I have no issues using direct authentication (browser prompts for jid/pwd). However, if I change the sample to use Candy.Core.attach (nearly a pass-thru to Strophe.Connection.attach) after performing a server side prebind (uisng MatriX), I seem to get stuck in some sort of idle loop that blasts empty messages to the XMPP server 3x a second.

Any ideas what is causing this looping and why the demo Candy UI doesn't appear when I use Candy.Core.attach?

Modified sample...

$(document).ready(function() {
    var httpbindUrl = 'http://xmpp.mydomain.net:7070/http-bind/';
    var chatRoom = '[email protected]';

    // These values come from a REST call to our services that perform
    // the prebind authentication (using MatriX, obviously)
    var jid = '[email protected]/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('[email protected]', 'password'); // <-- this works as expected
    });

The browser's console log displays...

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.

NOTE: Entries prepended with "LIBS:" are from strophe's low-level logging (level, msg). It should also be noted that the candy demo wraps strophe.js into a larger bundle called libs.bundle.js.

Upvotes: 0

Views: 601

Answers (2)

Tony
Tony

Reputation: 2066

It seems Openfire v3.9.3 BOSH implementation is 'quirky'. MatriX developers were able to work around the issue. As of MatriX v1.6.0.1 the scenario is resolved.

Upvotes: 0

fpsColton
fpsColton

Reputation: 873

Normally when you connect to a BOSH connection manager you have the ability to set the wait attribute on your first stanza (session creation request).

XEP-0124 Session Creation Response

Default value used by Strophe and Candy is 60. Can you confirm the value which MatriX is using when establishing your BOSH session?

Ex:

<body content='text/xml; charset=utf-8'
  from='[email protected]'
  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'/>

Upvotes: 0

Related Questions