Skip to content

Commit

Permalink
bosh.js: Make the inactivity value consistent. Set polling to half of…
Browse files Browse the repository at this point in the history
… inactivity.

xmpp-proxy-connector.js: Add comment to explain behaviour clearly.
  • Loading branch information
dhruvbird committed Mar 20, 2011
1 parent aa11b8a commit 1acdf0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/bosh.js
Expand Up @@ -42,6 +42,10 @@ var MAX_BOSH_CONNECTIONS = 3;
// that we are willing to accept.
var WINDOW_SIZE = 2;

// How much time should we hold a response object before sending
// and empty response to it?
var DEFAULT_INACTIVITY_SEC = 70;


function inflated_attrs(node) {
var xmlns = { };
Expand Down Expand Up @@ -172,8 +176,7 @@ exports.createServer = function(options) {
// responded to by us.
options.max_rid_sent = options.rid - 1;

// TODO: How much inactivity can we tolerate (in sec)?
options.inactivity = 120;
options.inactivity = DEFAULT_INACTIVITY_SEC;

options.window = WINDOW_SIZE;
add_held_http_connection(options, options.rid, res);
Expand Down Expand Up @@ -265,7 +268,9 @@ exports.createServer = function(options) {

// From streams, remove all entries that are
// null or undefined, and log this condition.
console.error(dutil.sprintf("get_streams_to_terminate::%s streams are in error:", sie.length));
if (sie.length > 0) {
console.error(dutil.sprintf("get_streams_to_terminate::%s streams are in error", sie.length));
}

return stt;
}
Expand Down Expand Up @@ -394,8 +399,8 @@ exports.createServer = function(options) {
sid: state.sid,
wait: state.wait,
ver: state.ver,
polling: 20,
inactivity: 60,
polling: state.inactivity / 2,
inactivity: state.inactivity,
requests: WINDOW_SIZE,
hold: state.hold,
from: sstate.to,
Expand Down
6 changes: 6 additions & 0 deletions src/xmpp-proxy-connector.js
Expand Up @@ -31,6 +31,12 @@ var _30_MINUTES_IN_SEC = 30 * 60;
var _60_MINUTES_IN_SEC = 60 * 60;


// Note: The way we calculate inactivity is not from the BOSH layer, but
// from the XMPP layer. If the client is making BOSH connections but sending
// or receiving empty packets (no XMPP XML stanzas), then his last
// activity timestamp shall NOT be updated, and after sufficient amount of
// time, the client shall be disconnected.


function XMPPProxyConnector(bosh_server) {
this.Proxy = xp.Proxy;
Expand Down

0 comments on commit 1acdf0e

Please sign in to comment.